Example #1
0
        string GetParamsForServiceCall()
        {
            PageSize = GetPropertyValue("pagesize", PageSize, 0);

            StringBuilder sb = new StringBuilder("");

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

            if (MaxTitleLength > 0)
            {
                sb.Append("&maxtitlelength=" + MaxTitleLength);
            }
            if (MaxDescriptionLength > 0)
            {
                sb.Append("&maxdesclength=" + MaxDescriptionLength);
            }
            if (PageSize > 0)
            {
                sb.Append("&pagesize=" + PageSize);
            }

            return(sb.ToString());
        }
Example #2
0
        string GetParamsForServiceCall()
        {
            //BlogId = GetPropertyValue("BlogId", BlogId, DefaultBlogId);

            StringBuilder sb = new StringBuilder("");

            sb.Append("?method=" + MethodName);
            sb.Append("&siteid=" + SiteId);
            sb.Append("&type=" + XMLType.ToString());
            if (BlogId > 0)
            {
                sb.Append("&blogid=" + BlogId);
            }

            if (MethodName == EMethods.GetPostList)
            {
                sb.Append(GetBlogPostList());
            }
            else if (MethodName == EMethods.GetPost)
            {
                sb.Append(GetBlogPost());
            }
            else if (MethodName == EMethods.GetCommentList)
            {
                sb.Append(GetBlogCommentList());
            }
            else if (MethodName == EMethods.GetArchivedPostList)
            {
                sb.Append(GetArchivedPostList());
            }
            else if (MethodName == EMethods.GetPostFileList)
            {
                sb.Append(GetBlogPostFileList());
            }

            if (MaxTitleLength > 0)
            {
                sb.Append("&maxtitlelength=" + MaxTitleLength);
            }
            if (MaxDescriptionLength > 0)
            {
                sb.Append("&maxdesclength=" + MaxDescriptionLength);
            }
            if (Parameters.Trim().Length > 0)
            {
                sb.Append("&prms=" + Parameters);
            }

            sb.Append(GetUriParameters(sb.ToString()));

            return(sb.ToString());
        }
Example #3
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()
        {
            ContestId      = GetPropertyValue("ContestId", ContestId, 0);
            ContestGroupId = GetPropertyValue("ContestGroupId", ContestGroupId, 0);
            UserId         = GetPropertyValue("UserId", UserId, 0);

            PageSize  = GetPropertyValue("pagesize", PageSize, 0);
            PageIndex = GetPropertyValue("pageindex", PageIndex, 0);

            StringBuilder sb = new StringBuilder("");

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

            if (ContestId > 0)
            {
                sb.Append("&contestid=" + ContestId);
            }
            if (ContestGroupId > 0)
            {
                sb.Append("&groupid=" + ContestGroupId);
            }
            if (UserId > 0)
            {
                sb.Append("&userid=" + UserId);
            }

            if (PageSize > 0)
            {
                sb.Append("&pagesize=" + PageSize);
            }
            if (PageIndex > 0)
            {
                sb.Append("&pageindex=" + PageIndex);
            }
            if (ContestEntryDate.Trim().Length > 0)
            {
                sb.Append("&date=" + ContestEntryDate);
            }
            if (Parameters.Trim().Length > 0)
            {
                sb.Append("&prms=" + Parameters);
            }

            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);
                        }
                    }
                }
            }

            return(sb.ToString());
        }
Example #4
0
        public XmlFile(System.IO.Stream fileStream)
        {
            // Test for XmlType
            try
            {
                doc = new XmlDocument();
                doc.Load(fileStream);
                type = XMLType.Text;
                foreach (XmlNode child in doc.ChildNodes)
                {
                    if (child.NodeType == XmlNodeType.Comment)
                    {
                        try
                        {
                            type = (XMLType)Enum.Parse(typeof(XMLType), child.Value);
                            break;
                        }
                        catch
                        {
                        }
                    }
                }
                return;
            }
            catch { doc = null; }
            finally
            {
                fileStream.Position = 0;
            }
            XmlBinaryReader r          = new XmlBinaryReader(EndianBitConverter.Little, fileStream);
            byte            headerByte = r.ReadByte();

            if (headerByte == 0x00)
            {
                type = XMLType.BXMLBig;
            }
            else if (headerByte == 0x01)
            {
                type = XMLType.BXMLLittle;
            }
            else
            {
                type = XMLType.BinXML;
            }
            r.BaseStream.Position = 0;
            r = null;

            // Create a text XML file
            if (type == XMLType.BinXML)
            {
                using (XmlBinaryReader reader = new XmlBinaryReader(EndianBitConverter.Little, fileStream))
                {
                    // Section 1
                    reader.ReadByte();   // Unique Byte
                    reader.ReadBytes(3); // Same Magic
                    reader.ReadInt32();  // File Length/Size

                    // Section 2
                    reader.ReadByte();   // Unique Byte
                    reader.ReadBytes(3); // Same Magic
                    reader.ReadInt32();  // Section 3 and 4 Total Length/Size

                    // Section 3 and 4
                    xmlStrings = new BinaryXmlString(reader);

                    // Section 5
                    reader.ReadInt32();
                    xmlElements = new BinaryXmlElement[reader.ReadInt32() / 24];
                    for (int i = 0; i < xmlElements.Length; i++)
                    {
                        xmlElements[i].elementNameID       = reader.ReadInt32();
                        xmlElements[i].elementValueID      = reader.ReadInt32();
                        xmlElements[i].attributeCount      = reader.ReadInt32();
                        xmlElements[i].attributeStartID    = reader.ReadInt32();
                        xmlElements[i].childElementCount   = reader.ReadInt32();
                        xmlElements[i].childElementStartID = reader.ReadInt32();
                    }

                    // Section 6
                    reader.ReadInt32();
                    xmlAttributes = new BinaryXmlAttribute[reader.ReadInt32() / 8];
                    for (int i = 0; i < xmlAttributes.Length; i++)
                    {
                        xmlAttributes[i].nameID  = reader.ReadInt32();
                        xmlAttributes[i].valueID = reader.ReadInt32();
                    }

                    // Build XML
                    doc = new XmlDocument();
                    doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"));
                    doc.AppendChild(doc.CreateComment(type.ToString()));
                    doc.AppendChild(xmlElements[0].CreateElement(doc, this));
                }
            }
            else if (type == XMLType.BXMLBig)
            {
                using (XmlBinaryReader reader = new XmlBinaryReader(EndianBitConverter.Big, fileStream))
                {
                    reader.ReadBytes(5);
                    doc = new XmlDocument();
                    doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"));
                    doc.AppendChild(doc.CreateComment(type.ToString()));
                    doc.AppendChild(reader.ReadBxmlElement(doc));
                }
            }
            else if (type == XMLType.BXMLLittle)
            {
                using (XmlBinaryReader reader = new XmlBinaryReader(EndianBitConverter.Little, fileStream))
                {
                    reader.ReadBytes(5);
                    doc = new XmlDocument();
                    doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"));
                    doc.AppendChild(doc.CreateComment(type.ToString()));
                    doc.AppendChild(reader.ReadBxmlElement(doc));
                }
            }
        }
Example #5
0
        string GetParamsForServiceCall()
        {
            PollId    = GetPropertyValue("PollId", PollId, 0);
            PageSize  = GetPropertyValue("pagesize", PageSize, 0);
            PageIndex = GetPropertyValue("pageindex", PageIndex, 0);

            StringBuilder sb = new StringBuilder("");

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

            if (PollId > 0)
            {
                sb.Append("&blogid=" + PollId);
            }
            if (Culture.Trim() != "")
            {
                sb.Append("&culture=" + Culture);
            }
            if (PageSize > 0)
            {
                sb.Append("&pagesize=" + PageSize);
            }
            if (PageIndex > 0)
            {
                sb.Append("&pageindex=" + PageIndex);
            }
            if (Parameters.Trim().Length > 0)
            {
                sb.Append("&prms=" + Parameters);
            }

            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["currpostid"] != null)
            {
                sb.Append("&currpostid=" + HttpContext.Current.Request["currpostid"].ToString());
            }
            else
            if (HttpContext.Current.Request["postid"] != null)
            {
                sb.Append("&currpostid=" + HttpContext.Current.Request["postid"].ToString());
            }

            return(sb.ToString());
        }
Example #6
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());
        }