protected void Page_Load(object sender, EventArgs e) { SPWeb spWeb = SPContext.Current.Web; var act = new Act(spWeb); int featureLicenseStatus = act.CheckFeatureLicense(ActFeature.MyWork); if (featureLicenseStatus != 0) { ErrorLabel.Text = act.translateStatus(featureLicenseStatus); ControlPanel.Visible = false; } //SPUser currentUser = spWeb.CurrentUser; //_userId = currentUser.ID; //_userName = currentUser.Name; //SPListItem spListItem = spWeb.SiteUserInfoList.GetItemById(_userId); //var profilePic = spListItem["Picture"] as string; //_profileImageUrl = !string.IsNullOrEmpty(profilePic) // ? profilePic.Remove(profilePic.IndexOf(',')).Replace("MThumb", "LThumb") // : "/_layouts/epmlive/images/mywork/DefaultProfilePic.jpg"; ControlPanel.Controls.Clear(); foreach (Control control in new[] { GetMyWorkControl() }) { ControlPanel.Controls.Add(control); } }
protected void Page_Load(object sender, EventArgs e) { Act act = new Act(Web); if (act.CheckFeatureLicense(ActFeature.AppsAndCommunities) != 0) { Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/applications/noact.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); } API.ApplicationDef appDef = API.Applications.GetApplicationInfo(Request["AppId"]); ApplicationName = appDef.Title; sFullWebUrl = Web.Url; try { SPList oList = Web.Lists.TryGetList("Installed Applications"); if (oList != null) { SPListItem li = oList.GetItemById(int.Parse(Request["CommId"])); API.Applications.AddAppToCommunity(li, int.Parse(Request["AppId"])); } sbOutput.Append("<div class=\"alert alert-success\">This application has been successfully added to the community.</div>"); } catch (Exception ex) { sbOutput.Append("<div class=\"alert alert-error\">There was an error adding this application to the community: " + ex.Message + "</div>"); } }
protected void Page_Load(object sender, EventArgs e) { Act act = new Act(Web); if (act.CheckFeatureLicense(ActFeature.AppsAndCommunities) != 0) { Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/applications/noact.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); } API.ApplicationDef appDef = API.Applications.GetApplicationInfo(Request["AppId"]); if (appDef.Community != "") { Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/applications/precheck.aspx?appid=" + Request["appid"] + "&CommId=", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, System.Web.HttpContext.Current); } else { string curapp = ""; try { curapp = Request["CommId"].ToString(); } catch { } if (curapp == "") { AppSettingsHelper helper = new AppSettingsHelper(); curapp = helper.CurrentAppId.ToString(); } SPList oList = Web.Lists.TryGetList("Installed Applications"); SPQuery query = new SPQuery(); query.Query = "<Where><IsNull><FieldRef Name='EXTID'/></IsNull></Where><OrderBy><FieldRef Name='Title'/></OrderBy>"; foreach (SPListItem li in oList.GetItems(query)) { System.Web.UI.WebControls.ListItem listitem = new System.Web.UI.WebControls.ListItem(li.Title, li.ID.ToString()); if (String.Equals(li.ID.ToString(), curapp)) { listitem.Selected = true; } ddlCommunity.Items.Add(listitem); } query = new SPQuery(); query.Query = "<Where><And><Eq><FieldRef Name='EXTID' /><Value Type='Number'>" + Request["AppId"] + "</Value></Eq><Eq><FieldRef Name='Status'/><Value Type='Text'>Installed</Value></Eq></And></Where>"; SPListItemCollection lic = oList.GetItems(query); if (lic.Count > 0) { pnlInstalled.Visible = true; bNavOnly = "true"; } } }
protected void Page_Load(object sender, EventArgs e) { Act act = new Act(Web); int activation = act.CheckFeatureLicense(ActFeature.AppsAndCommunities); sResponse = act.translateStatus(activation); }
protected void Page_Load(object sender, EventArgs e) { Act act = new Act(Web); if (act.CheckFeatureLicense(ActFeature.AppsAndCommunities) != 0) { Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/applications/noact.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); } }
internal static bool CheckActivationStatus(HtmlTextWriter output) { var act = new Act(SPContext.Current.Web); var activation = act.CheckFeatureLicense(ActFeature.WebParts); if (activation != 0) { output.Write(act.translateStatus(activation)); return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { Act act = new Act(Web); if (act.CheckFeatureLicense(ActFeature.AppsAndCommunities) != 0) { Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/applications/noact.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); } API.ApplicationDef appDef = API.Applications.GetApplicationInfo(Request["AppId"]); ApplicationName = appDef.Title; }
protected void Page_Load(object sender, EventArgs e) { Act act = new Act(Web); if (act.CheckFeatureLicense(ActFeature.AppsAndCommunities) != 0) { Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/applications/noact.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); } DataTable dtApps = API.Applications.GetApplications(""); GridView2.DataSource = dtApps; GridView2.DataBind(); }
private bool CheckForKeys() { var ndApplication = appDef.ApplicationXml.FirstChild.SelectSingleNode("Application"); if (ndApplication != null) { if (ndApplication.Attributes["RequiredFeatureKeys"] != null) { var reqKeys = ndApplication.Attributes["RequiredFeatureKeys"].Value; if (reqKeys != string.Empty) { var ParentMessageId = addMessage(ErrorLevels.NoError, "Activation Key Check", string.Empty, 0); var failed = false; var featureIds = reqKeys.Split(','); var act = new Act(oWeb); foreach (var featureId in featureIds) { try { if (act.CheckFeatureLicense((ActFeature)int.Parse(featureId)) == 0) { addMessage(ErrorLevels.NoError, CoreFunctions.getFeatureName(featureId), string.Empty, ParentMessageId); } else { addMessage(ErrorLevels.Error, CoreFunctions.getFeatureName(featureId), "Activation Key Not Installed", ParentMessageId); failed = true; } } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } } return(!failed); } } } return(true); }
public override void OnPublished(PSContextInfo contextInfo, ProjectPostPublishEventArgs e) { if (contextInfo == null) { throw new ArgumentNullException(nameof(contextInfo)); } if (e == null) { throw new ArgumentNullException(nameof(e)); } using (var myLog = new EventLog("EPM Live", ".", "EPM Live Publisher")) { myLog.MaximumKilobytes = 32768; using (var mySite = new SPSite(contextInfo.SiteGuid)) { var act = new Act(mySite.RootWeb); int iAct = act.CheckFeatureLicense(ActFeature.ProjectServer); if (iAct == 0) { using (var publisher = new Publisher(contextInfo, e)) { publisher.doPublish(); } } else { using (var connection = new SqlConnection(CoreFunctions.getConnectionString(mySite.WebApplication.Id))) { using (var command = new SqlCommand("update publishercheck set webguid=@webguid,logtext=@logtext, checkbit=0,status=@status,percentcomplete=0,laststatusdate=getdate() where projectguid=@projectguid", connection)) { command.Parameters.AddWithValue("@projectguid", e.ProjectGuid); command.Parameters.AddWithValue("@webguid", mySite.OpenWeb().ID); command.Parameters.AddWithValue("@status", 3); command.Parameters.AddWithValue("@logtext", $"Activation Error: {act.translateStatus(iAct)}"); } } } } } }
protected void Page_Load(object sender, EventArgs e) { Act act = new Act(Web); if (act.CheckFeatureLicense(ActFeature.AppsAndCommunities) != 0) { Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/applications/noact.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); } SPWeb oWeb = SPContext.Current.Web; sWebUrl = (oWeb.ServerRelativeUrl == "/") ? "" : oWeb.ServerRelativeUrl; sFullWebUrl = oWeb.Url; SPList oList = oWeb.Lists.TryGetList("Installed Applications"); if (oList != null) { LoadInstalled(oWeb, oList); } }
protected void Page_Load(object sender, EventArgs e) { Act act = new Act(Web); if (act.CheckFeatureLicense(ActFeature.AppsAndCommunities) != 0) { Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/applications/noact.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); } if (!Page.IsPostBack) { CheckForQuickLaunchField(SPContext.Current.Web); var dt = GetDataTable(); if (dt != null) { LoadCustom(dt); } } else { HandleNAcase(); } }
protected override void CreateChildControls() { act = new Act(SPContext.Current.Web); activation = act.CheckFeatureLicense(ActFeature.ResourcePlanner); if (activation != 0) { return; } strAction = Page.Request["action"]; curWeb = SPContext.Current.Web; { resUrl = CoreFunctions.getConfigSetting(curWeb, "EPMLiveResourceURL"); if (!string.IsNullOrWhiteSpace(resUrl)) { try { if (!resUrl.Equals(curWeb.ServerRelativeUrl, StringComparison.OrdinalIgnoreCase)) { if (resUrl.StartsWith("/")) { resWeb = curWeb.Site.OpenWeb(resUrl); } else { using (var tempSite = new SPSite(resUrl)) { resWeb = tempSite.OpenWeb(); if (!resWeb.Url.Equals(resUrl, StringComparison.OrdinalIgnoreCase)) { resWeb = null; } } } } else { resWeb = curWeb; } if (resWeb != null) { try { reslist = resWeb.Lists["Resources"]; } catch (Exception exception) { DiagTrace.WriteLine(exception); } if (reslist == null) { error = "Error: Resource list was not found."; } else { resview = reslist.DefaultView; var viewListBuilder = new StringBuilder(); foreach (SPView spView in resview.Views) { if (!spView.Hidden) { viewListBuilder.Append( spView.DefaultView ? $"<option selected value=\"{spView.Title.Replace(" ", "%20")}\">{spView.Title}</option>" : $"<option value=\"{spView.Title.Replace(" ", "%20")}\">{spView.Title}</option>"); } } viewList = viewListBuilder.ToString(); lnk = new LinkButton(); lnk.Click += lnk_Click; lnk.OnClientClick = $"Javascript:return postResources{ZoneIndex}{ZoneID}();"; lnk.Text = "<img src=\"/_layouts/images/epmlivegantt.GIF\" border=\"0\" style=\"vertical-align: middle;\"> View Resource Plan"; Controls.Add(lnk); } rcList = SPContext.Current.List; var view = SPContext.Current.ViewContext.View; toolbar = new ViewToolBar { TemplateName = "GanttViewToolBar" }; var context = SPContext.GetContext(Context, view.ID, rcList.ID, curWeb); toolbar.RenderContext = context; Controls.Add(toolbar); foreach (Control control in toolbar.Controls) { processControls(control, $"{ZoneIndex}{ZoneID}", view.ServerRelativeUrl, curWeb); } } } catch (Exception exception) { DiagTrace.WriteLine(exception); } } } }
protected override void CreateChildControls() { Act = new Act(SPContext.Current.Web); Activation = Act.CheckFeatureLicense(ActFeature.Timesheets); if (Activation != 0) { return; } var web = SPContext.Current.Web; { try { SpList = SPContext.Current.List; View = SPContext.Current.ViewContext.View; } catch (Exception exception) { Trace.WriteLine(exception); } if (View != null && SpList != null) { _viewToolbar = new ViewToolBar { TemplateName = "TSViewToolBar" }; var context = SPContext.GetContext(Context, View.ID, SpList.ID, SPContext.Current.Web); _viewToolbar.RenderContext = context; Controls.Add(_viewToolbar); foreach (Control control in _viewToolbar.Controls) { ProcessControls(control, FullGridId, View.ServerRelativeUrl, web); } _timeSheetMenu.Text = TimeSheetText; _timeSheetMenu.TemplateName = "ToolbarPMMenu"; _timeSheetMenu.ToolTip = TimeSheetText; _timeSheetMenu.MenuControl.Text = TimeSheetText; _timeSheetMenu.GetMenuItem("ApproveItems").ClientOnClickScript = $"approve{FullGridId}();"; _timeSheetMenu.GetMenuItem("RejectItems").ClientOnClickScript = $"reject{FullGridId}();"; _viewToolbar.Controls[0].Controls[1].Controls[0].Controls.AddAt(6, _timeSheetMenu); SPSecurity.RunWithElevatedPrivileges( delegate { try { using (var sqlConnection = new SqlConnection(CoreFunctions.getConnectionString(web.Site.WebApplication.Id))) { sqlConnection.Open(); using (var sqlCommand = new SqlCommand( "SELECT * from TSPERIOD where site_id=@siteid and locked = 0 order by period_id", sqlConnection) { CommandType = CommandType.Text }) { sqlCommand.Parameters.AddWithValue("@siteid", web.Site.ID); using (var dataReader = sqlCommand.ExecuteReader()) { while (dataReader.Read()) { _dropDownList.Items.Add( new ListItem( $"{dataReader.GetDateTime(1).ToShortDateString()} - {dataReader.GetDateTime(2).ToShortDateString()}", dataReader.GetInt32(0).ToString())); Periods.Add( dataReader.GetInt32(0), $"{dataReader.GetDateTime(1).ToShortDateString()} - {dataReader.GetDateTime(2).ToShortDateString()}"); } } _dropDownList.SelectedValue = Period.ToString(); } } } catch (Exception exception) { Trace.WriteLine(exception); } }); if (Page.IsPostBack) { Page.Response.Cookies[EpmLiveTsPeriod].Value = _dropDownList.SelectedValue; Page.Response.Cookies[EpmLiveTsPeriod].Expires = DateTime.Now.AddMinutes(30); } _dropDownList.ID = "ddlPeriod"; _dropDownList.SelectedIndexChanged += ddl_SelectedIndexChanged; _dropDownList.AutoPostBack = true; _dropDownList.EnableViewState = true; _buttonNext.Click += btn_Click; _buttonNext.ImageUrl = "/_layouts/epmlive/images/right.gif"; _buttonNext.EnableViewState = true; _buttonPrev.Click += btnPrev_Click; _buttonPrev.ImageUrl = "/_layouts/epmlive/images/left.gif"; _buttonPrev.EnableViewState = true; var pnl = new Panel(); pnl.Controls.Add( new LiteralControl( "<table border=\"0\"><tr><td class=\"ms-toolbar\" valign=\"center\"><div class=\"ms-buttoninactivehover\" onmouseover=\"this.className='ms-buttonactivehover'\" onmouseout=\"this.className='ms-buttoninactivehover'\">")); pnl.Controls.Add(_buttonPrev); pnl.Controls.Add(new LiteralControl("</div></td><td valign=\"center\">")); pnl.Controls.Add(_dropDownList); pnl.Controls.Add( new LiteralControl( "</td><td valign=\"center\"><div class=\"ms-buttoninactivehover\" onmouseover=\"this.className='ms-buttonactivehover'\" onmouseout=\"this.className='ms-buttoninactivehover'\">")); pnl.Controls.Add(_buttonNext); pnl.Controls.Add(new LiteralControl("</div></td></tr></table>")); _viewToolbar.Controls[0].Controls[1].Controls[0].Controls.AddAt(7, pnl); } } }
protected override void CreateChildControls() { Act = new Act(SPContext.Current.Web); Activation = Act.CheckFeatureLicense(ActFeature.Timesheets); if (Activation != 0) { return; } if (CoreFunctions.getConfigSetting(SPContext.Current.Site.RootWeb, "EPMLiveTSDisableApprovals").Equals(bool.TrueString, StringComparison.OrdinalIgnoreCase)) { _disabled = true; return; } var web = SPContext.Current.Web; { try { SpList = SPContext.Current.List; View = SPContext.Current.ViewContext.View; } catch (Exception exception) { Trace.WriteLine(exception); } if (View != null && SpList != null) { SPSecurity.RunWithElevatedPrivileges( delegate { try { Connection = new SqlConnection(CoreFunctions.getConnectionString(web.Site.WebApplication.Id)); Connection.Open(); using (var sqlCommand = new SqlCommand( "SELECT * from TSPERIOD where site_id=@siteid and locked = 0 order by period_id", Connection) { CommandType = CommandType.Text }) { sqlCommand.Parameters.AddWithValue("@siteid", web.Site.ID); using (var dataReader = sqlCommand.ExecuteReader()) { while (dataReader.Read()) { Periods.Add( dataReader.GetInt32(0), $"{dataReader.GetDateTime(1).ToShortDateString()} - {dataReader.GetDateTime(2).ToShortDateString()}"); } } } } catch (Exception exception) { Trace.WriteLine(exception); } }); } } }
protected void Page_Load(object sender, EventArgs e) { Act act = new Act(Web); if (act.CheckFeatureLicense(ActFeature.AppsAndCommunities) != 0) { Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/applications/noact.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); } API.ApplicationDef appDef = API.Applications.GetApplicationInfo(Request["AppId"]); ApplicationName = appDef.Title; sWebUrl = Web.ServerRelativeUrl; int jobid = 51; if (appDef.bIsConfigOnly) { jobid = 52; } XmlNode ndStatus = API.Applications.GetApplicationStatusMessage(Request["AppId"], SPContext.Current.Web, jobid); string sStatus = ndStatus.SelectSingleNode("Status").InnerText; string sMessage = ndStatus.SelectSingleNode("Message").InnerText; sMessage = System.Web.HttpUtility.HtmlDecode(sMessage); XmlDocument doc = new XmlDocument(); try { doc.LoadXml(sMessage); DataTable dt = new DataTable(); dt.Columns.Add("Status"); dt.Columns.Add("Message"); dt.Columns.Add("Detail"); dt.Columns.Add("Level"); appendTable(0, dt, doc.FirstChild); GridView2.DataSource = dt; GridView2.DataBind(); switch (maxError) { case 0: case 1: sbOutput.Append("<div class=\"alert alert-success\">This application has successfully passed the precheck.</div>"); break; case 5: sbOutput.Append("<div class=\"alert alert-warning\">This application has passed the precheck but there are 1 or more warnings. Click view details to get more information.</div>"); break; case 10: sbOutput.Append("<div class=\"alert alert-error\">This application has failed to pass the precheck. Click view details to get more information.</div>"); break; } ; } catch { sbOutput.Append("Error: " + sMessage); } }