Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the cmdSubmit 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 cmdSubmit_Click(object sender, EventArgs e)
        {
            DataTable dtListValue = null;
            try
            {

                if(Page.IsPostBack)
                {

                    string strToMailID = string.Empty;
                    string strCAMLQuery = string.Empty;
                    string strStatus = string.Empty;
                    string strActive = string.Empty;
                    bool blnSendMail = false;
                    objUtility = new CommonUtility();
                    objADS = new ActiveDirectoryService();

                    string strParentSiteURL = HttpContext.Current.Request.Url.ToString();
                    string strUserName = txtUserAcc.Text.ToString();

                    StringBuilder strMessage = new StringBuilder();

                    ServiceProvider objFactory = new ServiceProvider();
                    objMossController = objFactory.GetServiceManager("MossService");

                    dtListValue = new DataTable();
                    DataRow listRow;

                    strMessage.Append("User ID : " + strUserName);
                    strMessage.Append("<BR>Region: " + txtRegion.Text);
                    strMessage.Append("<BR>Purpose : " + txtPurpose.Text);
                    strToMailID = objADS.GetEmailID(strUserName);

                    if(Request.QueryString["teamId"] == null)
                    {
                        strCAMLQuery = "<OrderBy><FieldRef Name=\"LinkTitleNoMenu\" /></OrderBy><Where><Eq><FieldRef Name=\"LinkTitle\" /><Value Type=\"Computed\">" + strUserName + "</Value></Eq></Where>";
                        dtListValue = ((MOSSServiceManager)objMossController).ReadList(strParentSiteURL, USERACCESSREQUESTLIST, strCAMLQuery);

                        if(dtListValue.Rows.Count > 0)
                        {
                            listRow = dtListValue.Rows[0];
                            strStatus = listRow["Access_x0020_Approval_x0020_Stat"].ToString();
                            strActive = listRow["Active"].ToString();
                        }

                        if(string.Compare(strStatus, STATUSINPROGRESS, true) == 0)
                        {
                            lblMessage.Text = "You have already requested for access. Please contact administrator.";
                        }
                        else
                        {

                            if((string.IsNullOrEmpty(strStatus)) || ((string.Compare(strStatus, STATUSAPPROVED, true) == 0) && (string.Compare(strActive, "No", true) == 0)))
                            {
                                ((MOSSServiceManager)objMossController).CreateAccessRequest(strUserName, txtRegion.Text, txtPurpose.Text, string.Empty, USERACCESSREQUESTLIST);
                                blnSendMail = true;
                            }
                            else if(string.Compare(strStatus, STATUSREJECTED, true) == 0)
                            {
                                strMessage.Append("<BR><BR><font color='red'><b>Please note that the user's request has been rejected earlier</b></font>");
                                blnSendMail = true;
                            }
                        }

                        if(blnSendMail)
                        {
                            objUtility.SendMailforUserAccessRequest(strToMailID, strMessage.ToString());
                            lblMessage.Text = "Thank you for your access request. You will receive an email shortly in response.";
                        }

                    }
                    else
                    {
                        objUtility.SendTeamAccessRequestEmail(strToMailID, strMessage.ToString(), lblTeamName.Text, hidTeamOwner.Value);
                        lblMessage.Text = "Thank you for your access request. You will receive an email shortly in response.";
                    }

                    cmdSubmit.Visible = false;
                    cmdReset.Visible = false;
                }
            }
            catch(WebException webEx)
            {
                //  ExceptionPanel.Visible = true;
                // lblException.Visible = true;
                //  lblException.Text = webEx.Message;
            }
            catch(Exception ex)
            {
                CommonUtility.HandleException(HttpContext.Current.Request.Url.ToString(), ex);
            }
            finally
            {
                if(dtListValue != null)
                    dtListValue.Dispose();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends the email to user on print.
        /// </summary>
        /// <param name="results">The results.</param>
        /// <param name="parentSiteURL">The parent site URL.</param>
        /// <param name="strAddress">The STR address.</param>
        /// <param name="contextForMail">The context for mail.</param>
        public void SendEmailToUserOnPrint(string results, string parentSiteURL, string strAddress, SPContext contextForMail)
        {
            DataTable dtPrintChapterDetails = null;
            ActiveDirectoryService objADS = null;
            try
            {
                try
                {
                    objADS = new ActiveDirectoryService();
                }
                catch (Exception)
                {
                    objADS = new ActiveDirectoryService(contextForMail);
                }
                dtPrintChapterDetails = new DataTable();
                CommonUtility objUtility = new CommonUtility();
                objCommonDAL = new CommonDAL();
                string strToMailID = string.Empty;
                string strAccessLink = string.Empty;
                string strMessage = string.Empty;

                string strCamlQuery = @"<Where><Eq><FieldRef Name='RequestID' /><Value Type='Text'>" + results + "</Value></Eq></Where>";
                dtPrintChapterDetails = objCommonDAL.GetChapterPrintDetails(strCamlQuery, parentSiteURL, "DWB Chapter Print Details");

                if (dtPrintChapterDetails != null && dtPrintChapterDetails.Rows.Count > 0)
                {
                    /// Loop through the values in Chapter Print Details list.
                    foreach (DataRow dtRow in dtPrintChapterDetails.Rows)
                    {
                        try
                        {
                            strToMailID = objADS.GetEmailID(dtRow["UserName"].ToString());
                        }
                        catch (Exception)
                        {
                        }
                        strAccessLink = parentSiteURL + "/Pages/eWBPDFViewer.aspx?mode=chapter&requestID=" + results;

                        objUtility.SendMailforPrintUpdate(strToMailID, strAccessLink, parentSiteURL, strAddress, contextForMail);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (dtPrintChapterDetails != null)
                    dtPrintChapterDetails.Dispose();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates the book publish details.
        /// </summary>
        /// <param name="requestID">The request ID.</param>
        /// <param name="documentURL">The document URL.</param>
        /// <param name="parentSiteURL">The parent site URL.</param>
        /// <param name="currentUser">The current user.</param>
        /// <param name="isPublish">if set to <c>true</c> [is publish].</param>
        /// <param name="liveBookName">Name of the live book.</param>
        /// <param name="xmlDoc">The XML doc.</param>
        /// <param name="bookID">The book ID.</param>
        public void UpdateBookPublishDetails(string requestID, string documentURL, string parentSiteURL, string currentUser, bool isPublish, string liveBookName, XmlDocument xmlDoc, int bookID)
        {
            ActiveDirectoryService objAds = new ActiveDirectoryService();
            string strEmailID = objAds.GetEmailID(currentUser.ToString());

            objCommonDAL = new CommonDAL();
            objCommonDAL.UpdateBookPublishDetails(requestID, documentURL, parentSiteURL, currentUser, "DWB Book Print details Library", isPublish, liveBookName, xmlDoc, strEmailID, bookID);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// This method is used get details of dataowner from active directory
 /// </summary>
 /// <param name="DataOwnerNames">array of dataowners' name</param>
 /// <returns>collection of users</returns>
 private Users GetDataOwnerDetails(string[] dataOwnerNames)
 {
     Users objUsers = null;
     try
     {
         objADservice = new ActiveDirectoryService();
         SPSecurity.RunWithElevatedPrivileges(delegate()
       {
           objUsers = objADservice.GetUserDetails(dataOwnerNames);
       });
     }
     catch
     {
         throw;
     }
     return objUsers;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Sends the team access approval mail.
 /// </summary>
 /// <param name="toEmailID">To email ID.</param>
 /// <param name="subject">The subject.</param>
 /// <param name="messageBody">The message body.</param>
 public void SendTeamAccessApprovalMail(string toEmailID, string teamOwnerEmail, String subject, String messageBody)
 {
     StringDictionary objHeaders = null;
     objADS = new ActiveDirectoryService();
     try
     {
         objHeaders = new StringDictionary();
         objMossController = objFactory.GetServiceManager(MOSSSERVICE);
         //build String Dictionary Object
         objHeaders.Add("from", GetSenderEmailId());
         objHeaders.Add("to", toEmailID);
         objHeaders.Add("cc", teamOwnerEmail);
         objHeaders.Add("subject", subject);
         ((MOSSServiceManager)objMossController).SendFeedBackMail(objHeaders, messageBody);
     }
     catch(Exception ex)
     {
         HandleException("Common Utility", ex);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Sends the email for team access status.
        /// </summary>
        /// <param name="toEmailID">To email ID.</param>
        /// <param name="status">The status.</param>
        /// <param name="teamId">The team id.</param>
        public void SendEmailForTeamAccessStatus(string userID, string status, string teamId)
        {
            DataTable objDtListValue = null;
            objADS = new ActiveDirectoryService();

            string strSubject = string.Empty;
            string strBodyLine1 = string.Empty;
            string strBodyLine2 = string.Empty;
            string strSignature = string.Empty;
            string strCamlQuery = string.Empty;

            string strTeamOwner = string.Empty;
            string strTeamName = string.Empty;
            string strUserEmail = string.Empty;
            string strTeamOwnerEmail = string.Empty;

            /// Multi Team Owner Implementation
            /// Changed By: Yasotha
            /// Date : 21-Jan-2010
            string[] strTeamOwners;
            objMossController = objFactory.GetServiceManager(MOSSSERVICE);

            objDtListValue = ((MOSSServiceManager)objMossController).ReadList(HttpContext.Current.Request.Url.ToString(), TEAMREGISTRATIONLIST, "<Where><Eq><FieldRef Name='ID'/><Value Type=\"Counter\">" + teamId + "</Value></Eq></Where>");

            if(objDtListValue != null)
            {
                if(objDtListValue.Rows.Count > 0)
                {
                    strTeamOwner = objDtListValue.Rows[0]["TeamOwner"].ToString();
                    strTeamName = objDtListValue.Rows[0]["Title"].ToString();
                }
            }

            objDtListValue = ((MOSSServiceManager)objMossController).ReadList(HttpContext.Current.Request.Url.ToString(), USERACCESSREQUESTLIST, "<Where><Eq><FieldRef Name='ID'/><Value Type=\"Counter\">" + userID + "</Value></Eq></Where>");

            if(objDtListValue != null)
            {
                if(objDtListValue.Rows.Count > 0)
                {
                    strUserEmail = objDtListValue.Rows[0]["Email"].ToString();
                }
            }

            /// Multi Team Owner Implementation
            /// Changed By: Yasotha
            /// Date : 21-Jan-2010
            /// strTeamOwner - possible values are teamowner1;teamowner2 or teamowner
            /// If comes with multiple team owner, get email id of both team owner and send emails to both.
            if(strTeamOwner.IndexOf(";") != -1)
            {
                strTeamOwners = strTeamOwner.Split(";".ToCharArray());
            }
            else
            {
                strTeamOwners = new string[1];
                strTeamOwners[0] = strTeamOwner;
            }
            foreach(string teamOwner in strTeamOwners)
            {
                objDtListValue = ((MOSSServiceManager)objMossController).ReadList(HttpContext.Current.Request.Url.ToString(), USERACCESSREQUESTLIST, "<Where><Eq><FieldRef Name='DisplayName'/><Value Type=\"Text\">" + teamOwner + "</Value></Eq></Where>");

                if(objDtListValue != null)
                {
                    if(objDtListValue.Rows.Count > 0)
                    {
                        strTeamOwnerEmail = objDtListValue.Rows[0]["Email"].ToString();
                    }
                }

                StringBuilder sbMessageBody = new StringBuilder();
                if(status == "Rejected")
                {
                    strCamlQuery = "<OrderBy><FieldRef Name=\"Title\"/><FieldRef Name=\"Subject\" />" + "<FieldRef                                Name=\"BodyLine1\" /><FieldRef Name=\"BodyLine2\" />"
                                          + "<FieldRef Name=\"Signature\" /></OrderBy><Where><Eq>"
                                          + "<FieldRef Name=\"Category\" /><Value Type=\"Choice\">"
                                          + "Team Access Rejected</Value></Eq></Where>";
                }
                else
                {
                    strCamlQuery = "<OrderBy><FieldRef Name=\"Title\"/><FieldRef Name=\"Subject\" />" + "<FieldRef                                Name=\"BodyLine1\" /><FieldRef Name=\"BodyLine2\" />"
                                          + "<FieldRef Name=\"Signature\" /></OrderBy><Where><Eq>"
                                          + "<FieldRef Name=\"Category\" /><Value Type=\"Choice\">"
                                          + "Team Access Approval</Value></Eq></Where>";
                }

                try
                {
                    // Get the DocumentLibrary Deals
                    objDtListValue = ((MOSSServiceManager)objMossController).ReadList(HttpContext.Current.Request.Url.ToString(), EMAILTEMPLATELIST, strCamlQuery);

                    if(objDtListValue != null)
                    {
                        if(objDtListValue.Rows.Count > 0)
                        {
                            strSubject = objDtListValue.Rows[0]["Subject"].ToString();
                            strBodyLine1 = objDtListValue.Rows[0]["BodyLine1"].ToString();
                            strBodyLine2 = objDtListValue.Rows[0]["BodyLine2"].ToString();
                            strSignature = objDtListValue.Rows[0]["Signature"].ToString();
                            strBodyLine2 = strBodyLine2.Replace("{TeamOwner}", teamOwner);
                            strBodyLine2 = strBodyLine2.Replace("{TeamName}", strTeamName);
                            strSignature = strSignature.Replace("{RegardsFrom}", objADS.GetDisplayName(GetUserName()));
                            strSignature = strSignature.Replace("{Region}", SPContext.Current.Web.Title);
                            sbMessageBody.Append(strBodyLine1);
                            sbMessageBody.Append("<BR>" + strBodyLine2);
                            sbMessageBody.Append("<BR>" + strSignature);
                        }
                    }
                    SendTeamAccessApprovalMail(strUserEmail, strTeamOwnerEmail, strSubject, sbMessageBody.ToString());
                }

                catch(Exception ex)
                {
                    HandleException("DREAM - Access Request Event Handler", ex);
                }
                finally
                {
                    if(objDtListValue != null)
                        objDtListValue.Dispose();
                }
            }
        }