// Protected Methods (1) 

        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            string message = string.Empty;

            EPMLiveCore.Act act = new EPMLiveCore.Act(SPContext.Current.Web);
            int             featureLicenseStatus = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (featureLicenseStatus != 0)
            {
                Response.Write(act.translateStatus(featureLicenseStatus));
                return;
            }

            if (!string.IsNullOrEmpty(ContentLocation))
            {
                Uri uri;
                if (Uri.TryCreate(ContentLocation, UriKind.Absolute, out uri))
                {
                    SlideOutId = Path.GetFileNameWithoutExtension(uri.LocalPath);

                    if (IsSlideOutVisible())
                    {
                        try
                        {
                            DisplaySlideOut(uri);
                        }
                        catch (WebException)
                        {
                            ContentPanel.Visible = false;
                            message = string.Format(@"<strong>ERROR: </strong> Unable to connect to: {0}",
                                                    ContentLocation);
                        }
                    }
                    else
                    {
                        ContentPanel.Visible = false;
                    }
                }
                else
                {
                    message = string.Format(@"<strong>ERROR: </strong> {0} is not a valid URL.",
                                            ContentLocation);
                }
            }
            else
            {
                message = @"<strong>ERROR: </strong> Please provide a valid Content Location URL.";
            }

            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            DisplayMessage(message);
        }
コード例 #2
0
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            if (activation != 0)
            {
                output.Write(act.translateStatus(activation));
                return;
            }

            SPSecurity.RunWithElevatedPrivileges(() => RenderWebPartWithElevatedPermissions(output));
        }
コード例 #3
0
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            EPMLiveCore.Act act        = new EPMLiveCore.Act(SPContext.Current.Web);
            int             activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (activation != 0)
            {
                output.Write(act.translateStatus(activation));
                return;
            }

            SPWeb  cWeb  = SPContext.Current.Web;
            SPSite cSite = SPContext.Current.Site;

            var sPubComTxt = string.Empty;

            try {
                sPubComTxt = CoreFunctions.getConfigSetting(cWeb, "EPMLivePublicCommentText");
                sPubComTxt = HttpUtility.JavaScriptStringEncode(sPubComTxt);
            }
            catch { }

            if (string.IsNullOrEmpty(sPubComTxt))
            {
                sPubComTxt = "What are you working on?";
            }

            SPUser user = cWeb.CurrentUser;

            //get user picture from user id
            SPList     userInfoList   = cWeb.SiteUserInfoList;
            SPListItem userItem       = userInfoList.GetItemById(user.ID);
            string     userPictureUrl = cSite.MakeFullUrl(cWeb.ServerRelativeUrl) + "/_layouts/epmlive/images/O14_person_placeHolder_32.png";

            SPField fldPicture = null;

            try
            {
                fldPicture = userItem.Fields.GetFieldByInternalName("Picture");
            }
            catch (ArgumentException x)
            {
                fldPicture = null;
            }

            if (fldPicture != null)
            {
                try
                {
                    string[] picUrls = userItem[userItem.Fields.GetFieldByInternalName("Picture").Id].ToString().Split(',');
                    userPictureUrl = picUrls[0];
                }
                catch
                {
                    userPictureUrl = cSite.MakeFullUrl(cSite.ServerRelativeUrl) + "/_layouts/epmlive/images/O14_person_placeHolder_32.png";
                }
            }
            string userProfileUrl = cSite.MakeFullUrl(cWeb.ServerRelativeUrl) + "/_layouts/userdisp.aspx?Force=True&ID=" + user.ID + "&source=" + HttpContext.Current.Request.UrlReferrer;

            var defaultHeight = 500;

            output.Write("<script>" +
                         "curWebUrl = '" + cWeb.Url + "';" +
                         "curWebTitle = '" + HttpUtility.JavaScriptStringEncode(cWeb.Title) + "';" +
                         "userProfileUrl = '" + userProfileUrl + "';" +
                         "userEmail = '" + user.Email + "';" +
                         "userPicUrl = '" + userPictureUrl + "';" +
                         "userName = '******';" +
                         "numThreads = '" + this.NumThreads.ToString() + "';" +
                         "maxComments = '" + this.MaxComments.ToString() + "';" +
                         "sPubComTxt = '" + sPubComTxt + "';" +
                         "defaultHeight = '" + (int.TryParse(this.DefaultHeight, out defaultHeight) ? defaultHeight : 500) + "px';" +
                         "</script>");

            output.Write("<link rel=\"STYLESHEET\" type=\"text/css\" href=\"" + (cWeb.ServerRelativeUrl == "/" ? "" : cWeb.ServerRelativeUrl) + "/_layouts/epmlive/Comments.UI.css\"/>");
            output.Write("<link rel=\"STYLESHEET\" type=\"text/css\" href=\"" + (cWeb.ServerRelativeUrl == "/" ? "" : cWeb.ServerRelativeUrl) + "/_layouts/epmlive/CommentsWebPartStyle.css\"/>");

            output.Write(@"<div id='wrapper' class='divPublicCommentContainer'>
                            <table>
                                <tbody>
			                        <tr>
				                        <td valign='middle' align='left' id='commentTblc1'>
					                        <div id='comment-photo'>
                                                <img src='" + userPictureUrl + @"' class='circleborder' />
                                            </div>
				                        </td>
				                        <td valign='middle' align='left' style='padding-left:8px;padding-right:5px;' id='commentTblc2'>
					                        <div id='whatsup'>
                                                <div class='comment-box'>
                                                    <div id='inputPublicComment' class='comment-paragraph' contenteditable='true'>
                                                    </div>
                                                </div>
                                            </div>
				                        </td>
				                        <td valign='middle' align='left' id='commentTblc3'>
					                        <div class='general-button-wrapper'><a id='btnGeneralPost' href='#' class='btn-primary btn btn-small' style='text-decoration:none;'>Share</a></div>
				                        </td>
			                        </tr>
		                        </tbody>
                            </table>
                        </div>");

            output.Write("<div style=\"clear:both;\"></div>");

            output.Write("<div id=\"commentsWebPartMainContainer\" class=\"commentsWPMainContainer\">");
            output.Write("<div style=\"clear:both;\"></div>");

            output.Write(_loadingHtml);
            output.Write("<div style=\"clear:both;height:5px\"></div>");
            output.Write(_noCommentHtml);
            output.Write("</div>");
        }