private bool sendEmailNotification(string PageID, string PageName, string PageURL) { bool result = false; try { Configuration config = new Configuration(SPContext.Current.Site.ID, SPContext.Current.Web.ID); if(!string.IsNullOrEmpty(config.PAGE_NAME) && !string.IsNullOrEmpty(config.APPROVAL_LIST)) { ApproveData AD = new ApproveData(SPContext.Current.Site.ID, SPContext.Current.Web.ID, config.PAGE_NAME); string UserEmails = AD.GetEmailByPage(PageID); if(!string.IsNullOrEmpty(UserEmails)) { EmailControl emailControl = new EmailControl(); string bodyh = "You have a Policy Pending.</br>Please <a href='http://sharepoint/Pages/Pending.aspx'>Click Here</a> to acknowledge Pending Policies"; // string bodyh = string.Format("You need to approve the policy: <a href='{0}'>{0}</a>", PageURL, PageName); emailControl.SendEmialInternal(SPContext.Current.Site.ID, SPContext.Current.Site.Zone, SPContext.Current.Web.ID, UserEmails, bodyh, "Approve policy"); } } result = true; } catch{ } return result; }
protected void Page_Load(object sender, EventArgs e) { //string ApprovalList = ViewState[constants.ViewStateVariables.ApprovalPageList].ToString(); //string PageList = ViewState[constants.ViewStateVariables.PageList].ToString(); //string ApprovalList = "Policy Approval"; //string PageList = "Pages"; Configuration config = new Configuration(SPContext.Current.Site.ID, SPContext.Current.Web.ID); if (!string.IsNullOrEmpty(config.APPROVAL_LIST) && !string.IsNullOrEmpty(config.PAGE_NAME)) { GetPendingPolicies(config.PAGE_NAME, config.APPROVAL_LIST); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ErrorMessagec", string.Format("<script>alert('You need to configure the webpart');</script>")); } }
private void CalculateSLA(Guid siteID, Guid webID) { string globalMessage = string.Empty; try { Configuration config = new Configuration(siteID, webID); if (!string.IsNullOrEmpty(config.APPROVAL_LIST) && !string.IsNullOrEmpty(config.PAGE_NAME)) { ApproveData AD = new ApproveData(siteID, webID, config.PAGE_NAME, config.APPROVAL_LIST); AD.AnalyzeSLAInformation(); globalMessage = AD.ApproveMessageError; Microsoft.Office.Server.Diagnostics.PortalLog.LogString(globalMessage); } } catch (Exception ex) { Microsoft.Office.Server.Diagnostics.PortalLog.LogString("Vanick send email error: " + ex.Message + " stack trace: " + ex.StackTrace + " Global Messages: " + globalMessage); } }
private void GetPageData() { Configuration coni = new Configuration(SPContext.Current.Site.ID, SPContext.Current.Web.ID); Page.ClientScript.RegisterStartupScript(this.GetType(), "SetLABELPUBLISH", string.Format("<script>LABELPUBLISH = '{0}';</script>", coni.PUBLISH_LABEL_APPROVE)); Page.ClientScript.RegisterStartupScript(this.GetType(), "SetLABELPUBLISHNOAPPROVE", string.Format("<script>LABELPUBLISHNOAPPROVE = '{0}';</script>", coni.PUBLISH_LABEL_NO_APPROVE)); if (SPContext.Current != null) { if (SPContext.Current.List != null && SPContext.Current.List.Title.ToString().Equals(this.PageList)) { if (SPContext.Current.Item != null) { if (SPContext.Current.File.ParentFolder != null && SPContext.Current.File.ParentFolder.Name.Equals("Policies")) { Page.ClientScript.RegisterStartupScript(this.GetType(), "SetisCorrectPage", string.Format("<script>isCorrectPage = true;</script>")); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "SetisCorrectPage", string.Format("<script>isCorrectPage = false;</script>")); } ApproveData AD = new ApproveData(SPContext.Current.Site.ID, SPContext.Current.Web.ID, this.ApprovalList); approveDataResult = AD.GetApprovalinformation(SPContext.Current.Item.ID.ToString()); //SPContext.Current.Item[SPBuiltInFieldId.Created_x0020_By] SPFieldUserValue userValue = new SPFieldUserValue(SPContext.Current.Web, SPContext.Current.Item["Created By"].ToString()); //SPGroup currentApprovalGroup = SPContext.Current.Web.SiteGroups[this.ApprovalGroup]; string Author = string.Empty; SPUser cuser = SPContext.Current.Web.CurrentUser; if (userValue.User != null) { Page.ClientScript.RegisterStartupScript(this.GetType(), "SetAuthoremailPageID", string.Format("<script>currentemailAuthor = '{0}';</script>", userValue.User.Email)); Page.ClientScript.RegisterStartupScript(this.GetType(), "SetPageName", string.Format("<script>currentPageName = '{0}';</script>", SPContext.Current.File.Title)); if(SPContext.Current.Item.Fields.ContainsField(constants.columns.PageList.PageCategory) && SPContext.Current.Item[constants.columns.PageList.PageCategory] != null) Page.ClientScript.RegisterStartupScript(this.GetType(), "SetcurrentPageCategory", string.Format("<script>currentPageCategory = '{0}';</script>", SPContext.Current.Item[constants.columns.PageList.PageCategory].ToString())); if (SPContext.Current.Item.Fields.ContainsField(constants.columns.PageList.Version) && SPContext.Current.Item[constants.columns.PageList.Version] != null) Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetcurrentPageVersion", string.Format("<script type=\"text/javascript\">currentPageVersion = \"{0}\";</script>", SPContext.Current.Item[constants.columns.PageList.Version].ToString())); if (SPContext.Current.Item.Fields.ContainsField(constants.columns.PageList.NotifyStatus) && SPContext.Current.Item[constants.columns.PageList.NotifyStatus] != null) Page.ClientScript.RegisterStartupScript(this.GetType(), "SetcurrentPageNotifyStatus", string.Format("<script>currentPageNotifyStatus = {0};</script>", SPContext.Current.Item[constants.columns.PageList.NotifyStatus].ToString().ToLower())); if (SPContext.Current.Item.Fields.ContainsField(constants.columns.PageList.SLA) && SPContext.Current.Item[constants.columns.PageList.SLA] != null) Page.ClientScript.RegisterStartupScript(this.GetType(), "SetcurrentPageSLA", string.Format("<script>currentPageSLA = 'due by {0}';</script>", ((DateTime)SPContext.Current.Item[constants.columns.PageList.SLA]).ToString("f"))); else Page.ClientScript.RegisterStartupScript(this.GetType(), "SetcurrentPageSLA", string.Format("<script>currentPageSLA = '{0}';</script>", "")); Page.ClientScript.RegisterStartupScript(this.GetType(), "SetUserName", string.Format("<script>currentuserName = '******';</script>", cuser.Name)); //currentemailAuthor currentuserName Page.ClientScript.RegisterStartupScript(this.GetType(), "SetPageID", string.Format("<script>currentPageID = '{0}';</script>", SPContext.Current.Item.ID.ToString())); Page.ClientScript.RegisterStartupScript(this.GetType(), "SetPageURL", string.Format("<script>currentPageURL = '{0}';</script>", SPContext.Current.File.Url)); Page.ClientScript.RegisterStartupScript(this.GetType(), "SetListPage", string.Format("<script>currentListName = '{0}';</script>", this.PageList)); Page.ClientScript.RegisterStartupScript(this.GetType(), "SetListApproval", string.Format("<script>currentListApproval = '{0}';</script>", this.ApprovalList)); Page.ClientScript.RegisterStartupScript(this.GetType(), "Setcurrentsiteurl", string.Format("<script>currentsiteurl = '{0}';</script>", SPContext.Current.Web.Url)); Page.ClientScript.RegisterStartupScript(this.GetType(), "SetApprovePageData", string.Format("<script>ApprovePageData = {0};</script>", new JavaScriptSerializer().Serialize(approveDataResult))); //if (((SPListItem)SPContext.Current.Item).ModerationInformation.Status == SPModerationStatusType.Pending) //{ Page.ClientScript.RegisterStartupScript(this.GetType(), "SetPageStatus", string.Format("<script>approvePageStatus = '{0}';</script>", ((SPModerationStatusType)int.Parse(SPContext.Current.Item[constants.columns.PageList.ApprovalStatus].ToString())))); //Page.ClientScript.RegisterStartupScript(this.GetType(), "SetPageStatus", string.Format("<script>approvePageStatus = '{0}';</script>", ((SPListItem)SPContext.Current.Item).ModerationInformation.Status.ToString())); //} //Author = userValue.User.Name; if (cuser.LoginName == userValue.User.LoginName) { //Is the Author Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageAuthor", "<script type='text/javascript'>isPageAuthor = true;</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageAuthor", "<script type='text/javascript'>isPageAuthor = false;</script>"); //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageApprover", "<script>isPageApprover = false;</script>"); } SPFieldUserValueCollection localSharePointGroup = null; if (SPContext.Current.Item[constants.columns.PageList.ApprovalGroup] != null) { localSharePointGroup = new SPFieldUserValueCollection(((SPListItem)SPContext.Current.Item).Web, SPContext.Current.Item[constants.columns.PageList.ApprovalGroup].ToString()); if (localSharePointGroup[0].User == null) { //is group if (SPContext.Current.Web.Groups.GetByID(localSharePointGroup[0].LookupId) != null) { if (isUserinGroup(SPContext.Current.Site.ID, SPContext.Current.Web.ID, localSharePointGroup[0].LookupId, SPContext.Current.Web.CurrentUser)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageApprover", "<script>isPageApprover = true;</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageApprover", "<script>isPageApprover = false;</script>"); } } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageApprover", "<script>isPageApprover = false;</script>"); } } else { if (localSharePointGroup[0].User.LoginName.Equals(SPContext.Current.Web.CurrentUser.LoginName)) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageApprover", "<script>isPageApprover = true;</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageApprover", "<script>isPageApprover = false;</script>"); } } } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageApprover", "<script>isPageApprover = true;</script>"); } //SPGroup currentApprovalGroup = SPContext.Current.Web.SiteGroups[this.ApprovalGroup]; //else if (isUserinGroup(currentApprovalGroup, userValue.User)) //{ // //Is the approval // Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SetPageApprover", "<script>isPageApprover = true;</script>"); //} } //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ExeSetPageData", "SetPageData();", true); //LitaralPage.Text = string.Format("<label>Page Title: {0}, Page ID: {1}</label>",SPContext.Current.Item["Title"], SPContext.Current.Item.ID ); } } } }