// 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);
        }
Example #2
0
        private void ManageFields()
        {
            _cSite = SPContext.Current.Site;
            _cWeb  = SPContext.Current.Web;

            _solutionType = (!string.IsNullOrEmpty(Request.Params["type"])) ? Request.Params["type"] : string.Empty;
            _lstGuid      = (!string.IsNullOrEmpty(Request.Params["list"])) ? Request.Params["list"] : string.Empty;
            _copyFrom     = (!string.IsNullOrEmpty(Request.Params["copyfrom"])) ? Request.Params["copyfrom"] : string.Empty;

            if (!string.IsNullOrEmpty(_copyFrom))
            {
                SPList rqList = _cWeb.Lists[new Guid(_lstGuid)];
                if (rqList != null)
                {
                    SPListItem item = null;
                    try
                    {
                        item = rqList.GetItemById(int.Parse(_copyFrom));
                    }
                    catch { }

                    if (item != null)
                    {
                        _requestProjectName = item["Title"].ToString();
                        txtURL.Text         = _requestProjectName;
                    }
                }
            }

            Guid lockedWeb = CoreFunctions.getLockedWeb(Web);

            _parentWebGuid_B              = Web.ID.ToString("B");
            _parentWebUrl                 = Web.ServerRelativeUrl;
            _siteUrl                      = Site.Url;
            _siteHostName                 = Site.HostName;
            _currentWebRelativeUrl        = Web.ServerRelativeUrl;
            _sourceWebId                  = Web.ID.ToString();
            _curWebUrl                    = Web.Url;
            _solutionStoreServiceProxyUrl = Web.Url + SOLUTION_STORE_PROXY_URL;
            _baseURL                      = Web.ServerRelativeUrl == "/" ? Web.ServerRelativeUrl : Web.ServerRelativeUrl + "/";

            _includeContentClientId = InputformsectionIncludeContent.ClientID;
            _moreInfoUrlClientId    = txtURL.ClientID;
            _hasCreateSubSitePerm   = Web.DoesUserHavePermissions(Web.CurrentUser.LoginName, SPBasePermissions.ManageSubwebs);
            _moreInfoUrl            = Web.Url + MORE_INFO_URL;
            _smallParentUrl         = Web.Url + SMALL_PARENT_URL;
            _tempGalRedirect        = (Web.ServerRelativeUrl == "/" ? "" : Web.ServerRelativeUrl) + TEMP_GAL_REDIRECT;

            // get available features from corefunctions, which is currently hardcoded for testing purposes
            //ArrayList features = CoreFunctions.getActivatedFeatures();

            Act       act      = new Act(Web);
            ArrayList features = act.GetActivatedLevels();

            foreach (object array in features)
            {
                _featuresList += array.ToString() + ";#";
            }

            string _untranslatedGalleryToken = string.Empty;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                // go to locked web to find settings that specifies the template resource site
                using (SPWeb web = Site.OpenWeb(lockedWeb))
                {
                    try
                    {
                        _untranslatedGalleryToken = CoreFunctions.getConfigSetting(web, "EPMLiveTemplateGalleryURL", false, true);
                        switch (_untranslatedGalleryToken)
                        {
                        case "{Site}":
                            _templateResourceUrl = _cWeb.ServerRelativeUrl;
                            break;

                        case "{site}":
                            _templateResourceUrl = _cWeb.ServerRelativeUrl;
                            break;

                        case "{Root}":
                            _templateResourceUrl = CoreFunctions.getConfigSetting(web, "EPMLiveTemplateGalleryURL", true, true);
                            break;

                        case "{root}":
                            _templateResourceUrl = CoreFunctions.getConfigSetting(web, "EPMLiveTemplateGalleryURL", true, true);
                            break;
                        }
                    }
                    catch
                    {
                        _templateResourceUrl = _cWeb.ServerRelativeUrl;
                    }

                    if (string.IsNullOrEmpty(_templateResourceUrl) || _templateResourceUrl == " ")
                    {
                        _templateResourceUrl = _cWeb.ServerRelativeUrl;
                    }

                    if (!string.IsNullOrEmpty(_templateResourceUrl))
                    {
                        using (SPWeb templateResourceWeb = Site.AllWebs[_templateResourceUrl])
                        {
                            _workengineSvcUrl = templateResourceWeb.Url + WORKENGINE_WS_URL;
                        }
                    }
                    else
                    {
                        _workengineSvcUrl = Web.Url + WORKENGINE_WS_URL;
                    }

                    // get comp levels to filter templates by comp levels
                    try
                    {
                        _compLevels = web.AllProperties["CompLevel"].ToString();
                    }
                    catch { }
                    try
                    {
                        _compLevels = web.AllProperties["complevel"].ToString();
                    }
                    catch { }
                    //_workengineSvcUrl = "http://" + web.Site.HostName + (web.ServerRelativeUrl == "/" ? "" : web.ServerRelativeUrl) + WORKENGINE_WS_URL;
                    _projectWorkspaceSetting = CoreFunctions.getConfigSetting(web, "EPMLiveNewProjectWorkspaceType");

                    GridGanttSettings gSettings = new GridGanttSettings(_cWeb.Lists[new Guid(_lstGuid)]);

                    _newItemName      = !string.IsNullOrEmpty(_lstGuid) ? gSettings.NewMenuName : "workspace";
                    _newItemName      = !string.IsNullOrEmpty(_newItemName) ? _newItemName : "workspace";
                    _newItemNameLwrCs = _newItemName.ToLower();
                    _listName         = _cWeb.Lists[new Guid(_lstGuid)].Title.ToLower();
                    _templateType     = _newItemNameLwrCs;

                    if (_templateType.Equals("department site", StringComparison.CurrentCultureIgnoreCase))
                    {
                        _templateType = "department";
                    }

                    SPList curList = _cWeb.Lists[new Guid(_lstGuid)];


                    if (!string.IsNullOrEmpty(gSettings.RollupLists))
                    {
                        string[] tRollupLists = gSettings.RollupLists.Split(',');
                        _rListName            = tRollupLists[0].Split('|')[0];
                    }

                    _reqListName     = gSettings.RequestList;
                    _doNotDelRequest = gSettings.DeleteRequest.ToString();

                    string epmLiveCreateNewSettings = CoreFunctions.getConfigSetting(web, "EPMLiveCreateNewSettings");

                    if (!string.IsNullOrEmpty(epmLiveCreateNewSettings))
                    {
                        EPMLiveCore.API.PropertyHash props = new EPMLiveCore.API.PropertyHash(CoreFunctions.getConfigSetting(web, "EPMLiveCreateNewSettings"), ";#", '|', '^');
                        if (props != null && props[0].Keys.Count > 0)
                        {
                            _defaultCreateNewOpt       = props[0]["Default"].ToString();
                            _isCreateFromOnlineAvail   = bool.Parse(props[1]["Online"].ToString());
                            _isCreateFromLocalAvail    = bool.Parse(props[1]["Local"].ToString());
                            _isCreateFromExistingAvail = bool.Parse(props[1]["Existing"].ToString());
                        }
                        else
                        {
                            _defaultCreateNewOpt = "online";
                        }
                    }
                    else
                    {
                        _defaultCreateNewOpt = "existing";
                    }

                    _createFromLiveTemp = CoreFunctions.getConfigSetting(web, "EPMLiveUseLiveTemplates");
                }
            });
        }
        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>");
        }
Example #4
0
        public override void Execute(Guid contentDbId)
        {
            // get a reference to the current site collection's content database
            SPWebApplication webApplication = this.Parent as SPWebApplication;

            string[] arrUsers = new string[20];

            string LevelUsers = "";

            bool mustprocess = false;

            int actType = 0;

            SortedList LevelList = Act.GetAllAvailableLevels(out actType);

            if (actType == 3)
            {
                mustprocess = true;
            }
            else
            {
                for (int i = 0; i < 20; i++)
                {
                    string scount = "";
                    try
                    {
                        scount = CoreFunctions.getFeatureLicenseUserCount(i);
                        if (scount != "Unlimited" && scount != "0")
                        {
                            mustprocess = true;
                        }
                    }
                    catch { }
                    arrUsers[i] = "";
                }
            }

            if (!mustprocess)
            {
                return;
            }

            foreach (SPSite site in webApplication.Sites)
            {
                if (actType == 3)
                {
                    string sLevelUsers = "";
                    try
                    {
                        sLevelUsers = site.RootWeb.Properties["workengineusers1000"].ToString();
                    }
                    catch { }
                    if (sLevelUsers != "")
                    {
                        site.RootWeb.Properties["workengineusers1000"] = "";
                        site.RootWeb.Properties.Update();
                        LevelUsers = LevelUsers + "," + sLevelUsers;
                    }
                }
                else
                {
                    for (int i = 0; i < 20; i++)
                    {
                        string sUsers = "";
                        try
                        {
                            sUsers = site.RootWeb.Properties["workengineusers" + i].ToString();
                        }
                        catch { }
                        if (sUsers != "")
                        {
                            site.RootWeb.Properties["workengineusers" + i] = "";
                            site.RootWeb.Properties.Update();
                            arrUsers[i] = arrUsers[i] + "," + sUsers;
                        }
                    }
                }


                site.Dispose();
            }
            SPFarm farm = webApplication.Farm;

            if (actType == 3)
            {
                ProcessV3Users(farm, LevelUsers, LevelList);
            }
            else
            {
                for (int i = 0; i < 20; i++)
                {
                    ProcessUsers(farm, arrUsers[i], i);
                }
            }
        }
        protected override void CreateChildControls()
        {
            act = new EPMLiveCore.Act(SPContext.Current.Web);
            int activation = act.CheckFeatureLicense(EPMLiveCore.ActFeature.WebParts);

            if (activation != 0)
            {
                return;
            }

            //base.CreateChildControls();
            MainTable = new HtmlTable();
            InitializeBubbleChartInputs();

            // Diagnostics
            Chart.PropTrace            = Page.Request.QueryString["charttrace"] != null;
            Chart.ChartLookupField     = Page.Request.QueryString["lookupfield"];
            Chart.ChartLookupFieldList = Page.Request.QueryString["lookupfieldlist"];

            if (_myProvider != null)
            {
                Chart.ReportFilterWebPartId = _myProvider.ReportID;
            }

            Chart.PropChartWebPartId = ID;

            Chart.BubbleChartUserSettings = GetPersistedBubbleChartPersonalizations();

            _litVfChart = new LiteralControl(Chart.GetHtml(ZoneID + ZoneIndex));

            var currentWebPartManager = WebPartManager.GetCurrentWebPartManager(Page);

            if (currentWebPartManager != null &&
                ((String.IsNullOrEmpty(PropChartSelectedList.Trim()) &&
                  currentWebPartManager.DisplayMode.Name == "Design") ||
                 (PropChartSelectedList.Trim() == "<Select List>" && currentWebPartManager.DisplayMode.Name == "Browse")))
            {
                ConfigureChartVerbiageLiteral.Text =
                    "<P><DIV class=\"UserGeneric\"><br />To configure the EPM Live Chart Web Part <a href=\"javascript:MSOTlPn_ShowToolPane2Wrapper('Edit', this, '" +
                    ID + "')\">click here</a>.<br /><br /></DIV></P>";
                Controls.Add(ConfigureChartVerbiageLiteral);
            }

            if (IsBubbleChart())
            {
                using (var site = new SPSite(SPContext.Current.Site.Url))
                {
                    using (var web = site.OpenWeb(SPContext.Current.Web.ID))
                    {
                        var selectedList = web.Lists[PropChartSelectedList];

                        if (selectedList == null)
                        {
                            return;
                        }
                        PopulateBubbleChartInputsWithInitialValues(selectedList);

                        if (Chart.BubbleChartUserSettings != null && Chart.BubbleChartUserSettings.IsValid && selectedList.ID == Chart.BubbleChartUserSettings.ListId)
                        {
                            SetBubbleChartInputSelectionsBasedOnPersonalizationSettings(Chart.BubbleChartUserSettings, selectedList);
                        }
                        else
                        {
                            SetBubbleChartInputsBasedOnWebPartProperties();
                        }
                    }
                }
            }

            var tableRow  = new HtmlTableRow();
            var chartCell = new HtmlTableCell();

            chartCell.Attributes.Add("valign", "top");

            var userSettingsCell = new HtmlTableCell();

            userSettingsCell.Attributes.Add("valign", "top");
            userSettingsCell.Attributes.Add("style", "padding-top:12px;");

            chartCell.Controls.Add(_litVfChart);

            MainTable.Attributes.Add("width", "100%");

            if (PropChartShowBubbleChartInputsInWebPart)
            {
                chartCell.Attributes.Add("width", "80%");
                userSettingsCell.Controls.Add(UserSettingsTable);
            }

            tableRow.Controls.Add(chartCell);

            if (IsBubbleChart())
            {
                tableRow.Controls.Add(userSettingsCell);
            }

            MainTable.Controls.Add(tableRow);

            Controls.Add(MainTable);
        }