/// <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(); } }