private void LoadCC(int woNum, string proj) { RolesBLL roleLogic = new RolesBLL(); WorkOrder.WOroleTextDisplayDataTable rolesDT = roleLogic.GetWOrolesByWOnumProj(woNum, proj); string ls_cc; ldapClient userObject = new ldapClient(); UserRecord ud; foreach (WorkOrder.WOroleTextDisplayRow roleRow in rolesDT) { if (roleRow.worl_email) { ud = userObject.SearchUser(roleRow.worl_uid.ToString()); ls_cc = ud.Email.ToString(); mailmsg.CC.Add(ls_cc); } } }
protected void btnSearch_Click(object sender, EventArgs e) { lblBeforeAdd.Visible = false; userAdded.Visible = false; try { string userId = tbxEmpno.Text; ldapClient userObject = new ldapClient(); UserRecord ud = userObject.SearchUser(userId); ldapUserInfo.Visible = true; lblLast.Text = ud.LastName.ToString(); lblFirst.Text = ud.FirstName.ToString(); lblEmail.Text = ud.Email.ToString(); lblDepNo.Text = ud.OrganizationCode.ToString(); lblDepName.Text = ud.DepartmentName.ToString(); lblManager.Text = ud.ManagerId.ToString(); } catch (Exception ex) { lblBeforeAdd.Visible = true; lblBeforeAdd.Text = ex.Message; } }
public static void InsertEligFileContent() { HRAEligFile eobj = new HRAEligFile(); DataSet ds1 = new DataSet(); ds1.Clear(); ds1 = GetEligAddrData(); DataSet ds2 = new DataSet(); ds2.Clear(); ds2 = GetEligStatData(); DataSet dschange1 = new DataSet(); dschange1 = eobj.GetAddrChgData(ds1); DataSet dschange2 = new DataSet(); dschange2 = eobj.GetStatChgData(ds2); string _filecontent1 = ds1.GetXml(); string _filecontent2 = ds2.GetXml(); string _filecontent3; if (dschange1.Tables[0].Rows.Count > 0) { _filecontent3 = dschange1.GetXml(); } else { _filecontent3 = dschange1.GetXmlSchema(); } string _filecontent4; if (dschange2.Tables[0].Rows.Count > 0) { _filecontent4 = dschange2.GetXml(); } else { _filecontent4 = dschange2.GetXmlSchema(); } string _uid = HttpContext.Current.User.Identity.Name; ldapClient lobj = new ldapClient(); UserRecord ud = new UserRecord(); ud = lobj.SearchUser(_uid); string _username = ud.FirstName + ", " + ud.LastName; string cmdstr1 = "DELETE FROM [hra_content] WHERE [category] = 'HRAElig'"; string cmdstr2 = "INSERT INTO [hra_content] " + "([category] " + ",[source] " + ",[content] " + ",[createduser]) " + "VALUES " + "('HRAElig' " + ",'EligAddr' " + ",@filecontent1 " + ",@username)"; string cmdstr3 = "INSERT INTO [hra_content] " + "([category] " + ",[source] " + ",[content] " + ",[createduser]) " + "VALUES " + "('HRAElig' " + ",'EligStat' " + ",@filecontent2 " + ",@username)"; string cmdstr4 = "INSERT INTO [hra_content] " + "([category] " + ",[source] " + ",[content] " + ",[createduser]) " + "VALUES " + "('HRAElig' " + ",'ChgEligAddr' " + ",@filecontent3 " + ",@username)"; string cmdstr5 = "INSERT INTO [hra_content] " + "([category] " + ",[source] " + ",[content] " + ",[createduser]) " + "VALUES " + "('HRAElig' " + ",'ChgEligStat' " + ",@filecontent4 " + ",@username)"; try { if (connect == null || connect.State == ConnectionState.Closed) { connect.Open(); } command = new SqlCommand(cmdstr1, connect); command.ExecuteNonQuery(); command.Dispose(); command = new SqlCommand(cmdstr2, connect); command.Parameters.AddWithValue("@filecontent1", _filecontent1); command.Parameters.AddWithValue("@username", _username); command.ExecuteNonQuery(); command.Dispose(); command = new SqlCommand(cmdstr3, connect); command.Parameters.AddWithValue("@filecontent2", _filecontent2); command.Parameters.AddWithValue("@username", _username); command.ExecuteNonQuery(); command.Dispose(); command = new SqlCommand(cmdstr4, connect); command.Parameters.AddWithValue("@filecontent3", _filecontent3); command.Parameters.AddWithValue("@username", _username); command.ExecuteNonQuery(); command.Dispose(); command = new SqlCommand(cmdstr5, connect); command.Parameters.AddWithValue("@filecontent4", _filecontent4); command.Parameters.AddWithValue("@username", _username); command.ExecuteNonQuery(); command.Dispose(); } finally { connect.Close(); } }
public bool Send(string eFrom, string eTo, string subj, string body, int woNum, int woRespNum, string proj) { ldapClient userObject = new ldapClient(); UserRecord ud; ud = userObject.SearchUser(eFrom.ToString()); eFrom = ud.Email.ToString(); ud = new UserRecord(); ud = userObject.SearchUser(eTo.ToString()); eTo = ud.Email; LoadCC(woNum, proj); //MailMessage mailmsg = new MailMessage(); MailAddress mailFrom = new MailAddress(eFrom); //+ "@acme.com" MailAddress mailRecip = new MailAddress(eTo); //+ "@acme.com" if (mailmsg.CC.Count > 0) { MailAddress[] MAarray = new MailAddress[0]; foreach (MailAddress ma in mailmsg.CC) { if (ma.Address == mailRecip.Address || ma.Address == mailFrom.Address) { Array.Resize(ref MAarray, MAarray.Length + 1); MAarray[MAarray.Length - 1] = ma; //Array.Copy(ma,MAarray,1); } } if (MAarray.Length > 0) { foreach (MailAddress ma1 in MAarray) { mailmsg.CC.Remove(ma1); } } } mailmsg.From = mailFrom; mailmsg.ReplyTo = mailFrom; //mailTo.Add(mailRecip); mailmsg.To.Add(mailRecip); mailmsg.Subject = subj; mailmsg.Body = body; SmtpClient mailClient = new SmtpClient(); mailClient.UseDefaultCredentials = true; mailClient.Port = 25; try { mailClient.Send(mailmsg); WorkOrderBLL WOobj = new WorkOrderBLL(); int eMailNum = WOobj.GetMaxEmailNum(woNum, proj) + 1; bool YNemail = WOobj.InsertEmailRecord(eMailNum, woNum, woRespNum, proj, mailmsg.From.ToString(), mailmsg.To.ToString(), mailmsg.CC.ToString(), mailmsg.Subject, mailmsg.Body, DateTime.Now); } catch (SmtpFailedRecipientsException recExc) { for (int i = 0; i < recExc.InnerExceptions.Length; i++) { SmtpStatusCode statCd = recExc.InnerExceptions[i].StatusCode; if ((statCd == SmtpStatusCode.MailboxBusy) || (statCd == SmtpStatusCode.MailboxUnavailable)) { System.Threading.Thread.Sleep(5000); mailClient.Send(mailmsg); } } } catch (SmtpException smtpEx) { string errmsg = smtpEx.InnerException.Message; string errmsg2 = smtpEx.Message; string statusCd = smtpEx.StatusCode.ToString(); return(false); } catch (Exception Ex) { string ExMsg = Ex.Message; } return(true); }
protected void l_onAuthenticate(object sender, AuthenticateEventArgs e) { Login1.FailureText = ""; lblError.Text = ""; bool auth; ldapAuthentication ldAuth = new ldapAuthentication(); UserAccess ua = new UserAccess(); ldapClient userObject = new ldapClient(); UserRecord ud; try { bool _locked = ua.isLocked(Login1.UserName.ToString()); if (!_locked) { try { auth = ldAuth.AuthenticateUser(Login1.UserName.ToString(), Login1.Password.ToString()); e.Authenticated = auth; bool _access = ua.hasAccess(Login1.UserName.ToString()); if (auth == true && _access) { ua.ValidLogin(Login1.UserName.ToString()); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, Login1.UserName.ToString(), DateTime.Now, DateTime.Now.AddMinutes(60), false, ""); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); Response.Cookies.Add(authCookie); Session["uid"] = Login1.UserName.ToString(); Session["pwd"] = EncryptDecrypt.Encrypt(Login1.Password.ToString()); ud = userObject.SearchUser(Login1.UserName.ToString()); Session["userName"] = ud.FirstName.ToString() + " " + ud.LastName.ToString(); Audit.auditUserSession(Session["uid"].ToString(), Session["userName"].ToString(), Session.SessionID.ToString()); // Redirect the user to the originally requested page string redirectURL = FormsAuthentication.GetRedirectUrl(Login1.UserName.ToString(), false); if (redirectURL.Equals("")) { Response.Redirect("~/Home.aspx"); } //auditEBA.auditUser(HttpContext.Current.Session.SessionID, Login1.UserName.ToString()); } else { e.Authenticated = false; throw (new Exception("You are not approved to access the application!")); } } catch (Exception ex) { try { ua.InvalidLogin(Login1.UserName.ToString()); } catch (Exception ex1) { lblError.Text = ex1.Message; } e.Authenticated = false; throw ex; } } else { e.Authenticated = false; lblError.Text = "Account Locked. Contact your administrator to unlock your account."; } } catch (Exception ex) { Login1.FailureText = ex.Message; } }
protected void btnUpdate_Click(object sender, EventArgs e) { // First check their LDAP Password . . . ldapAuthentication ldapAuth = new ldapAuthentication(); try { ldapAuth.AuthenticateUser(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1).ToString(), txtBxPassword.Text); } catch (Exception ex) { lblText = Label1.Text; Label1.Text = ex.Message.ToString();//"Your LDAP UID and/or password did not authenticate. Please try again."; return; } lblText = Label1.Text;// = "Your LDAP UID and/or password did not authenticate. Please try again."; DataView dv = (DataView)ObjectDataSource1.Select(); //string ls_val; //string ls_val2; woApprovalBLL apprvLogic = new woApprovalBLL(); bool lb_rtn = false; foreach (DataRow dr in dv.Table.Rows) { if (Convert.ToInt32(dr["wapr_Approver"]) == Convert.ToInt32(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1))) { int li_val = Convert.ToInt32(dr["wapr_AprvNum"]); int li_val1 = li_wonum; string ls_val = ls_proj; DateTime ldt_val = Convert.ToDateTime(dr["wapr_AprvDate"].ToString()); int li_val2 = Convert.ToInt32(dr["wapr_Approver"]); bool lb_val = chkBxApproval.Checked; //Convert.ToBoolean(dr["wapr_AprvCode"]); DateTime ldt_val2 = DateTime.Now; string ls_val2 = txtBxComments.Text; // dr["wapr_comments"].ToString(); bool lb_val2 = Convert.ToBoolean(dr["wapr_required"]); bool lb_val3 = Convert.ToBoolean(dr["wapr_emailFlag"]); lb_rtn = apprvLogic.UpdateWOAprvlRecord(li_val, li_val1, ls_val, ldt_val, li_val2, lb_val, ldt_val2, ls_val2, lb_val2, lb_val3, li_val); GridView1.DataBind(); btnUpdate.Visible = false; btnApprove.Visible = false; lnkBtnReturn.Visible = true; Label2.Visible = false; Label3.Visible = false; Label4.Visible = false; Label5.Visible = false; chkBxApproval.Visible = false; txtBxPassword.Visible = false; txtBxComments.Visible = false; txtBxUser.Visible = false; Label1.Text = "Update was successful."; } } WorkOrderBLL woLogic = new WorkOrderBLL(); WorkOrder.WorkOrderDataTable WrkOrds = woLogic.GetWorkOrdersByWOnumProj(li_wonum, ls_proj); WorkOrder.WorkOrderRow WrkOrd = WrkOrds[0]; string host = Request.ServerVariables["SERVER_NAME"]; //HttpContext.Current.Request.Url.Host; SmtpEmail mailMessage = new SmtpEmail(); string ls_to = ""; RolesBLL WOroleLogic = new RolesBLL(); WorkOrder.WOroleTextDisplayDataTable woRoleDT; woRoleDT = WOroleLogic.GetWOrolesByWOnumProj(li_wonum, ls_proj); foreach (WorkOrder.WOroleTextDisplayRow roleRow in woRoleDT) { if (Convert.ToBoolean(roleRow["worl_aprvl"]) == true) { ls_to = ls_to + "," + roleRow["worl_uid"].ToString(); } } ldapClient userObject = new ldapClient(); UserRecord ud; ud = userObject.SearchUser(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1)); lb_rtn = mailMessage.Send(User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1), ls_to, "GO/NoGO ACTION - " + WrkOrd.word_Proj.ToString() + " WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString(), "WO# " + li_wonum + " - " + WrkOrd.word_Title.ToString() + " has received a Go/NoGo action from " + ud.FirstName.ToUpper() + " " + ud.LastName.ToUpper() + "." + " Log into the EBS Work Order Module for details." + Environment.NewLine + Environment.NewLine + "http://" + host + "/WorkOrder/EditWO.aspx?word_WOnum=" + li_wonum.ToString() + "&word_Proj=" + WrkOrd.word_Proj.ToString() + Environment.NewLine + Environment.NewLine + "The comment left on this Go/NoGo action is as follows:" + Environment.NewLine + Environment.NewLine + (Convert.ToBoolean(chkBxApproval.Checked) ? "GO! " : "NO Go! ") + Environment.NewLine + Environment.NewLine + txtBxComments.Text + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine + "PLEASE DO NOT RESPOND TO THIS EMAIL!" , li_wonum, 0, WrkOrd.word_Proj.ToString()); }