Пример #1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            string parameterError = string.Empty;

            requestInfo = new ServiceRequestInfo();

            bool RequestInfoOK = ServiceHelper.FillRSSServiceRequestInfo(Request.Params, ref parameterError, ref requestInfo);

            // Create the response info
            try
            {
                ServiceResponseInfo responseInfo = new ServiceResponseInfo();
                responseInfo = ServiceHelper.CallService(this.portalSettings.PortalID, -1, Rainbow.Settings.Path.ApplicationFullPath, ref requestInfo, this);

                if (!RequestInfoOK || requestInfo.Tag != 0)
                {
                    responseInfo.ServiceStatus = string.Empty;
                    if (requestInfo.Tag != 0)
                    {
                        responseInfo.ServiceStatus = "ERROR! Unknown value of parameter Tag! ";
                    }
                    if (!RequestInfoOK)
                    {
                        responseInfo.ServiceStatus += "WARNING! Bad request. Problem with value of " + parameterError;
                    }
                    responseInfo.ServiceDescription += " (" + responseInfo.ServiceStatus + ")";
                }

                StringBuilder sb;
                sb = new StringBuilder(string.Empty, 4000);

                // Header
                sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                sb.Append("<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\" \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">");
                sb.Append("<rss version=\"0.91\">");
                sb.Append("<channel>");
                sb.Append("<title>" + Server.HtmlEncode(responseInfo.ServiceTitle) + "</title>");
                sb.Append("<link>" + Server.HtmlEncode(responseInfo.ServiceLink) + "</link>");
                sb.Append("<description>" + Server.HtmlEncode(responseInfo.ServiceDescription) + "</description>");
                sb.Append("<image>");
                sb.Append("<title>" + Server.HtmlEncode(responseInfo.ServiceImageTitle) + "</title>");
                sb.Append("<url>" + Server.HtmlEncode(responseInfo.ServiceImageUrl) + "</url>");
                sb.Append("<link>" + Server.HtmlEncode(responseInfo.ServiceImageLink) + "</link>");
                sb.Append("<width>100</width>");
                sb.Append("<height>40</height>");
                sb.Append("</image>");

                // Loop on each Item of the responseInfo collection
                foreach (ServiceResponseInfoItem srii in responseInfo.Items)
                {
                    sb.Append("<item>");
                    sb.Append("<title>" + Server.HtmlEncode(srii.Title) + "</title>");
                    sb.Append("<link>" + Server.HtmlEncode(srii.Link) + "</link>");
                    sb.Append("<description>" + Server.HtmlEncode(srii.Description) + "</description>");
                    sb.Append("</item>");
                }

                // Footer
                sb.Append("</channel>");
                sb.Append("</rss>");

                RSSLiteral.Text = sb.ToString();
                //xml1.DocumentContent = sb.ToString();
            }
            catch (Exception ex)
            {
                Rainbow.Configuration.ErrorHandler.HandleException("FATAL ERROR IN CSS SERVICE", ex);

                RSSLiteral.Text = ServiceHelper.CreateErrorRSSFeed(
                    "FATAL ERROR IN CSS SERVICE! (Click here to go to Forum)",
                    "http://rainbow.duemetri.net/ASPNetForums/",
                    Server.HtmlEncode("Please check the parameters. Error: " + ex.ToString()));
            }
        }
        /// <summary>
        /// Fills the portal DS.
        /// </summary>
        /// <param name="responseInfo">The response info.</param>
        /// <returns></returns>
        private DataSet FillPortalDS(ref ServiceResponseInfo responseInfo)
        {
            DataSet ds = new DataSet();

            try
            {
                ds = CreatePortalDS(ds);

                string  strTmp, strLink, strBaseLink;
                string  strModuleFriendlyName, strModuleID, strItemID;
                string  strTabID, strModuleGuidID, strModuleTitle;
                string  strLocate;
                DataRow dr;

                for (int row = 0; row < responseInfo.Items.Count; row++)
                {
                    dr = ds.Tables["ServiceItemList"].NewRow();

                    //ServiceResponseInfoItemExt item = (ServiceResponseInfoItemExt) responseInfo.Items[row];
                    ServiceResponseInfoItem item = (ServiceResponseInfoItem)responseInfo.Items[row];
                    strModuleFriendlyName = item.FriendlyName;
                    strModuleID           = item.ModuleID.ToString();
                    strItemID             = item.ItemID.ToString();
                    strTabID        = item.PageID.ToString();
                    strModuleGuidID = item.GeneralModDefID.ToString().ToUpper();
                    strModuleTitle  = item.ModuleTitle;
                    strLocate       = "mID=" + strModuleID + "&ItemID=" + strItemID;

                    if (requestInfo.ShowID)
                    {
                        strModuleFriendlyName += " (ID=" + strModuleID + ")";
                        strModuleTitle        += " (ID=" + strModuleID + ")";
                    }


                    if (requestInfo.LocalMode)
                    {
                        strBaseLink = Path.ApplicationRoot + "/";
                    }
                    else
                    {
                        strBaseLink = requestInfo.Url;
                    }

                    switch (strModuleGuidID)
                    {
                    case "2D86166C-4BDC-4A6F-A028-D17C2BB177C8":     //Discussions
                        strLink = strBaseLink + "DesktopModules/Discussion/DiscussionView.aspx?" + strLocate;
                        break;

                    case "2502DB18-B580-4F90-8CB4-C15E6E531012":     //Tasks
                        strLink = strBaseLink + "DesktopModules/Tasks/TasksView.aspx?" + strLocate;
                        break;

                    default:
                        strLink = strBaseLink + "DesktopDefault.aspx?tabID=" + strTabID;
                        break;
                    }
                    if (requestInfo.PortalAlias.Length != 0)
                    {
                        strLink += "&Alias=" + requestInfo.PortalAlias;
                    }


                    //if (showImage)
                    //{
                    //	dr["Image"] = "<a href='" + strLink + "'>" + strModuleGuidID + ".gif" + "</a>";
                    //}

                    if (showModuleFriendlyName)
                    {
                        dr["Module"] = strModuleFriendlyName;
                    }

                    if (showModuleTitle)
                    {
                        dr["Module Title"] = strModuleTitle;
                    }

                    if (showTitle)
                    {
                        if (strModuleGuidID == "0B113F51-FEA3-499A-98E7-7B83C192FDBB" || //Html Document
                            strModuleGuidID == "2B113F51-FEA3-499A-98E7-7B83C192FDBB")   //Html WYSIWYG Edit (V2)
                        {
                            // We use the database field [rb.Modules].[ModuleTitle]:
                            strTmp = strModuleTitle;
                        }
                        else
                        {
                            if (item.Title == string.Empty)
                            {
                                strTmp = "missing";
                            }
                            else
                            {
                                strTmp = item.Title;
                            }
                        }
                        dr["Title"] = "<a href='" + strLink + "' Target='" + Target + "'>" + strTmp + "</a>";
                    }

                    if (showDescription)
                    {
                        if (item.Description == string.Empty)
                        {
                            strTmp = "missing";
                        }
                        else
                        {
                            strTmp = item.Description;
                        }

                        // Remove any html tags:
                        HTMLText html = SearchHelper.DeleteBeforeBody(Server.HtmlDecode(strTmp));
                        dr["Description"] = html.InnerText;
                    }

                    if (showCreatedByUser)
                    {
                        if (item.CreatedByUser == string.Empty)
                        {
                            strTmp = string.Empty;
                        }
                        else
                        {
                            strTmp = item.CreatedByUser;
                        }
                        // 15/7/2004 added localization by Mario Endara [email protected]
                        if (strTmp == "unknown")
                        {
                            strTmp = General.GetString("UNKNOWN", "unknown");
                        }
                        dr["User"] = strTmp;
                    }

                    if (showCreatedDate)
                    {
                        try
                        {
                            strTmp = item.CreatedDate.ToShortDateString();
                        }
                        catch
                        {
                            strTmp = string.Empty;
                        }

                        // If date is an empty string the date "1/1/1900" is returned.
                        if (strTmp == "1/1/1900")
                        {
                            strTmp = string.Empty;
                        }
                        dr["Date"] = strTmp;
                    }

                    if (showLink)
                    {
                        dr["Link"] = "<a href='" + strLink + "' Target='" + Target + "'>" + strLink + "</a>";
                    }

                    if (showTabName)
                    {
                        if (item.PageName == string.Empty)
                        {
                            strTmp = "missing";
                        }
                        else
                        {
                            strTmp = item.PageName;
                        }

                        if (requestInfo.ShowID && strTmp != "missing")
                        {
                            strTmp = strTmp + "(ID=" + item.PageID + ")";
                        }

                        if (requestInfo.PortalAlias.Length != 0)
                        {
                            dr["Tab"] = "<a href='" + strBaseLink + "DesktopDefault.aspx?tabID=" + strTabID + "&Alias=" +
                                        requestInfo.PortalAlias + "' Target='" + Target + "'>" + strTmp + "</a>";
                        }
                        else
                        {
                            dr["Tab"] = "<a href='" + strBaseLink + "DesktopDefault.aspx?tabID=" + strTabID +
                                        "' Target='" + Target + "'>" + strTmp + "</a>";
                        }
                    }

                    ds.Tables["ServiceItemList"].Rows.Add(dr);
                }
            }
            catch (Exception e)
            {
                lblStatus.Text = "Error when reading list. Problem: " + e.Message;
                return(null);
            }
            return(ds);
        }