/// <summary>
 /// Constructor
 /// </summary>
 public AssignmentListWebPart()
 {
     culture        = new SlkCulture();
     displaySummary = true;
     listScope      = true;
     ToolTip        = culture.Format(culture.Resources.AlwpWebPartToolTipFormat, this.Title, this.Description);
 }
예제 #2
0
        void DownloadSettingsPage_Load(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    // The page URL is of the following two forms:
                    //   1. http://.../DownloadSettings.aspx/<guid>/SlkSettings.xml
                    //   2. http://.../DownloadSettings.aspx/Default/SlkSettings.xml
                    // The following code parses <guid> into <siteGuid> (for case 1), or sets
                    // <siteGuid> to null (for case 2).
                    Uri uri = Request.Url;
                    if ((uri.Segments.Length < 3) ||
                        !String.Equals(uri.Segments[uri.Segments.Length - 1], "SlkSettings.xml",
                                       StringComparison.OrdinalIgnoreCase))
                    {
                        throw new SafeToDisplayException(culture.Resources.DownloadSettingsIncorrectUrl);
                    }
                    string siteGuidOrDefault = uri.Segments[uri.Segments.Length - 2];
                    siteGuidOrDefault = siteGuidOrDefault.Substring(0, siteGuidOrDefault.Length - 1);
                    Guid?spSiteGuid;
                    if (String.Equals(siteGuidOrDefault, "Default",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        spSiteGuid = null;
                    }
                    else
                    {
                        try
                        {
                            spSiteGuid = new Guid(siteGuidOrDefault);
                        }
                        catch (FormatException)
                        {
                            throw new SafeToDisplayException(
                                      culture.Resources.DownloadSettingsIncorrectUrl);
                        }
                        catch (OverflowException)
                        {
                            throw new SafeToDisplayException(
                                      culture.Resources.DownloadSettingsIncorrectUrl);
                        }
                    }

                    // set <settingXml> to the SLK Settings XML for <spSiteGuid> -- use the default
                    // SLK Settings XML if <spSiteGuid> is null or <spSiteGuid> is not configured for
                    // use with SLK
                    string settingsXml = null;
                    if (spSiteGuid != null)
                    {
                        settingsXml = SlkAdministration.GetSettingsXml(spSiteGuid.Value);
                    }
                    if (settingsXml == null)
                    {
                        // load the default SLK Settings
                        settingsXml = File.ReadAllText(Server.MapPath("SlkSettings.xml.dat"));
                    }

                    // write the XML to the browser
                    Response.ContentType = "text/xml";
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    // if the following line is un-commented, clicking "Open" in the IE File Download
                    // dialog gives an error: "Cannot find 'C:\Documents and Settings\<user>\Local
                    // Settings\Temporary Internet Files\Content.IE5\<path>\SlkSettings[1].xml'"
                    //Response.AddHeader("content-disposition", "attachment");
                    Response.Write(settingsXml);
                }
                catch (SafeToDisplayException ex)
                {
                    // an expected exception occurred
                    Response.Clear();
                    Response.ContentType = "text/html";
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.Write(culture.Format(culture.Resources.AdminErrorPageHtml, ex.Message));
                    Response.End();
                }
            }
            catch (System.Threading.ThreadAbortException)
            {
                // thrown by Response.End above
                throw;
            }
            catch (Exception ex)
            {
                // an unexpected exception occurred
                Response.Clear();
                Response.ContentType = "text/html";
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Write(culture.Format(culture.Resources.AdminErrorPageHtml, Server.HtmlEncode(string.Format(CultureInfo.CurrentUICulture, culture.Resources.SeriousErrorDownloadSettings, ex))));
                Response.End();
            }
        }