private void setUserName() { CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(Convert.ToInt32(Session["UserId"])); if (user.UserName != null) { } }
protected void btnSubmit_click(object sender, EventArgs e) { CRM.Data.Entities.SecUser user = SecUserManager.GetByUserName(txtUserName.Text.Trim()); if (user.UserName != null && user.Password != null) { string password = SecurityManager.Decrypt(user.Password); if (user.UserId > 0 && password.Equals(txtPassword.Text.Trim())) { lblError.Visible = false; DoAuthenticate(user); } else { lblError.Visible = true; lblError.Text = "Invalid User Name or Password!"; createLoginLog(user.UserId, false); } } else { lblError.Visible = true; lblError.Text = "Invalid User Name or Password!"; return; } }
public CRM.Data.Entities.SecUser getSecUser(int superVisorId) { string connectionString = ConfigurationManager.ConnectionStrings["ClaimRuler"].ConnectionString; string str_query = @"SELECT * FROM SecUser WHERE UserId = @userId"; CRM.Data.Entities.SecUser SecUserObj = new CRM.Data.Entities.SecUser(); using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand(str_query, conn)) { cmd.Parameters.AddWithValue("@userId", superVisorId); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Email"] != null) { SecUserObj.Email = Convert.ToString(reader["Email"]); } if (reader["UserName"] != null) { SecUserObj.UserName = Convert.ToString(reader["UserName"]); } } conn.Close(); } return(SecUserObj); }
protected void btnExport_click(object sender, EventArgs e) { int userID = 0; List <LeadTask> tasks = null; CRM.Data.Entities.SecUser user = null; userID = Core.SessionHelper.getUserId(); if (userID > 0) { tasks = getSelectedTasks(); user = SecUserManager.GetByUserId(userID); if (user != null && user.Email != null && user.emailPassword != null) { try { Core.GCalendarHelper.export(user.Email, Core.SecurityManager.Decrypt(user.emailPassword), tasks); lblMessage.Text = "Export completed."; lblMessage.CssClass = "ok"; } catch (Exception ex) { lblMessage.CssClass = "error"; lblMessage.Text = "Export failed."; } } } //help.ExportToGoogleCalendar("https://www.google.com/calendar/feeds/default/private/full", tasks); }
private void setUserName() { CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(Convert.ToInt32(Session["UserId"])); if (user.UserName != null) { lblUserWelcome.Text = "Welcome (" + user.UserName + ")"; } }
protected void btnEmailInvoice_Click(object sender, EventArgs e) { string reportPath = null; int invoiceID = 0; Invoice invoice = null; int port = 0; string password = null; CRM.Data.Entities.SecUser user = null; string subject = "Invoice"; int userID = Core.SessionHelper.getUserId(); string bodyText = "Invoiced is attached."; //Page.Validate("emailInvoice"); //if (!Page.IsValid) // return; try { invoiceID = Convert.ToInt32(ViewState["InvoiceID"].ToString()); reportPath = generateInvoicePDF(invoiceID); user = SecUserManager.GetByUserId(userID); if (user != null && !string.IsNullOrEmpty(reportPath)) { invoice = InvoiceManager.Get(invoiceID); string[] recipients = txtEmailTo.Text.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); string[] attachments = new string[] { reportPath }; port = Convert.ToInt32(user.emailHostPort); password = Core.SecurityManager.Decrypt(user.emailPassword); //new email functionality by chetu string crsupportEmail = ConfigurationManager.AppSettings["smtpEmail"].ToString(); string crsupportEmailPassword = ConfigurationManager.AppSettings["smtpPassword"].ToString(); Core.EmailHelper.sendEmail(crsupportEmail, recipients, null, subject, bodyText, attachments, crsupportEmail, crsupportEmailPassword); /////////////////// //Core.EmailHelper.sendEmail(user.Email, recipients, null, subject, bodyText, attachments, user.emailHost, port, user.Email, password); // add copy of invoice to documet list updateDocumentLog(reportPath, invoice.ClaimID); lblMessage.Text = "Invoice mailed successfully."; lblMessage.CssClass = "ok"; } } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblMessage.Text = "Unable to email invoice."; lblMessage.CssClass = "error"; } }
public void bindEvents() { int clientID = SessionHelper.getClientId(); int DaysinMonth = 0; DateTime fromDate = DateTime.Now; DateTime toDate = DateTime.Now; CRM.Data.Entities.SecUser user = null; int userID = SessionHelper.getUserId(); user = SecUserManager.GetById(userID); if (user != null) { if (WebDayView1.Visible) { fromDate = SchedulerManager.GetScheduleFromDate(WebScheduleInfo1); toDate = SchedulerManager.GetScheduleEndDate(WebDayView1); } else if (WebMonthView1.Visible) { fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); DaysinMonth = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month); toDate = fromDate.AddMonths(1).AddTicks(-1); } List <LeadTask> appointments = null; // get events from all users and show on scheduler Expression <Func <Task, bool> > predicate = PredicateBuilder.True <CRM.Data.Entities.Task>(); predicate = predicate.And(LeadTask => LeadTask.creator_id == clientID); predicate = predicate.And(LeadTask => LeadTask.TaskType == 2); predicate = predicate.And(LeadTask => LeadTask.owner_id == userID); predicate = predicate.And(LeadTask => LeadTask.start_date >= fromDate && LeadTask.start_date <= toDate); appointments = TasksManager.GetEvents(predicate); Resource resource = new Resource(); resource.DataKey = userID.ToString(); resource.Name = user.FirstName + " " + user.LastName; WebScheduleInfo1.Activities.Clear(); WebScheduleInfo1.VisibleResources.Clear(); WebScheduleInfo1.VisibleResources.Add(resource); SchedulerManager.BindAppointment(WebScheduleInfo1, appointments); } }
protected void btnEmailInvoice_Click(object sender, EventArgs e) { string decryptedInvoiceID = null; string reportPath = null; int invoiceID = 0; int port = 0; string password = null; CRM.Data.Entities.SecUser user = null; string subject = "Invoice"; string bodyText = "Invoice is attached."; int userID = Core.SessionHelper.getUserId(); decryptedInvoiceID = Core.SecurityManager.DecryptQueryString(hf_encryptedInvoiceID.Value); int.TryParse(decryptedInvoiceID, out invoiceID); if (invoiceID > 0) { try { reportPath = Core.ReportHelper.generateInvoicePDF(invoiceID); user = SecUserManager.GetByUserId(userID); if (user != null && !string.IsNullOrEmpty(reportPath)) { //invoice = InvoiceManager.Get(invoiceID); string[] recipients = txtEmailTo.Text.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); string[] attachments = new string[] { reportPath }; port = Convert.ToInt32(user.emailHostPort); password = Core.SecurityManager.Decrypt(user.emailPassword); Core.EmailHelper.sendEmail(user.Email, recipients, null, subject, bodyText, attachments, user.emailHost, port, user.Email, password); lblMessage.Text = "Invoice emailed successfully."; lblMessage.CssClass = "ok"; } } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblMessage.Text = "Unable to email invoice."; lblMessage.CssClass = "error"; } finally { // reset hf_encryptedInvoiceID.Value = "0"; } } }
public CRM.Data.Entities.SecUser GetSupervisor(int supervisorId) { CRM.Data.Entities.SecUser user = null; user = (from x in claimRulerDBContext.SecUser where x.UserId == supervisorId select x ).FirstOrDefault <CRM.Data.Entities.SecUser>(); return(user); }
protected void btnEmailInvoice_Click(object sender, EventArgs e) { string reportPath = null; int invoiceID = 0; Data.Entities.LeadInvoice invoice = null; int port = 0; string password = null; CRM.Data.Entities.SecUser user = null; string subject = "Invoice"; int userID = Core.SessionHelper.getUserId(); string bodyText = "Invoiced is attached."; Page.Validate("emailInvoice"); if (!Page.IsValid) { return; } try { invoiceID = Convert.ToInt32(ViewState["InvoiceID"].ToString()); reportPath = generateInvoicePDF(invoiceID); user = SecUserManager.GetByUserId(userID); if (user != null && !string.IsNullOrEmpty(reportPath)) { invoice = LeadInvoiceManager.Get(invoiceID); string[] recipient = new string[] { txtEmailTo.Text }; string[] attachments = new string[] { reportPath }; port = Convert.ToInt32(user.emailHostPort); password = Core.SecurityManager.Decrypt(user.emailPassword); Core.EmailHelper.sendEmail(user.Email, recipient, null, subject, bodyText, attachments, user.emailHost, port, user.Email, password); updateDocumentLog(reportPath, (int)invoice.PolicyTypeID); lblMessage.Text = "Invoice mailed successfully."; lblMessage.CssClass = "ok"; } } catch (Exception ex) { lblMessage.Text = "Unable to email invoice."; lblMessage.CssClass = "error"; } }
protected void btnEmailInvoice_Click(object sender, EventArgs e) { int invoiceID = 0; string reportPath = null; Invoice invoice = null; CRM.Data.Entities.SecUser user = null; string[] recipient = null; string subject = "Invoice"; string bodyText = "Attached is invoice."; string[] attachments = null; string password = null; int port = 0; user = SecUserManager.GetByUserId(userID); foreach (GridViewRow row in gvInvoice.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox cbxApproved = row.FindControl("cbxApproved") as CheckBox; if (cbxApproved.Checked) { invoiceID = (int)gvInvoice.DataKeys[row.RowIndex].Value; reportPath = generateInvoicePDF(invoiceID); if (!string.IsNullOrEmpty(reportPath)) { invoice = InvoiceManager.Get(invoiceID); recipient = new string[] { invoice.CarrierInvoiceProfile.AccountingContactEmail }; attachments = new string[] { reportPath }; port = Convert.ToInt32(user.emailHostPort); password = Core.SecurityManager.Decrypt(user.emailPassword); Core.EmailHelper.sendEmail(user.Email, recipient, null, subject, bodyText, attachments, user.emailHost, port, user.Email, password); } } } } }
protected void bindData() { List <Email> emails = null; Client client = null; //default imap host string imapHost = "imap.gmail.com";; int port = 993; bool useSSL = true; // get current user CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(userID); // get client associated with user client = ClientManager.Get(clientID); if (user != null && client != null && user.Email != null && user.emailPassword != null) { // show email where we are trying to import lblEmail.Text = string.Format("{0}/export", user.Email); string inboxPath = Server.MapPath("~/inbox"); if (!string.IsNullOrEmpty(client.imapHost)) { imapHost = client.imapHost; port = client.imapHostPort ?? 993; useSSL = client.imapHostUseSSL ?? true; } try { emails = GCalendarHelper.getGMailEmail(imapHost, port, useSSL, user.Email, SecurityManager.Decrypt(user.emailPassword)); } catch (Exception ex) { lblMessage.Text = "Unable to read emails. Please verify IMAP settings."; lblMessage.CssClass = "error"; } } gvMails.DataSource = emails; gvMails.DataBind(); }
protected void impersonateClient(Client client) { List <SecRoleModuleManager.secRoleModuleGet> resRolePermission = new List <SecRoleModuleManager.secRoleModuleGet>(); string userData = null; CRM.Data.Entities.SecUser user = null; user = client.SecUser; Session["UserId"] = client.SecUser.UserId; Session["UserName"] = client.SecUser.UserName; Session["RoleId"] = client.SecUser.SecRole.RoleId.ToString(); // 201307-29 Session["ClientId"] = client.SecUser.ClientID; Session["ClientShowTask"] = (client.isShowTasks ?? true); userData = string.Format("{0}|{1}|{2} {3}|{4}", user.SecRole.RoleName, user.SecRole.RoleId, user.FirstName, user.LastName, user.Email); var ticket = new FormsAuthenticationTicket ( 1, client.SecUser.UserId.ToString(), DateTime.Now, DateTime.Now.AddMinutes(120), true, userData, //(client.SecUser.SecRole.RoleName + "|" + client.SecUser.SecRole.RoleId.ToString()), FormsAuthentication.FormsCookiePath ); string encryptedTicket = FormsAuthentication.Encrypt(ticket); Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)); Session["rolePermission"] = resRolePermission = SecRoleModuleManager.getRolePermission(client.SecUser.SecRole.RoleId).ToList(); var url = FormsAuthentication.DefaultUrl; Response.Redirect(url); }
public static void notifyUser(string description, int claimid, string recipient) { StringBuilder emailBody = new StringBuilder(); string password = null; string[] recipients = null; string smtpHost = null; int smtpPort = 0; //string siteUrl = ConfigurationManager.AppSettings["siteUrl"].ToString(); string subject = "Red-Flag Alert: " + description + " Claim # " + claimid; CRM.Data.Entities.SecUser user = null; // get logged in user int userID = SessionHelper.getUserId(); // get logged in user email info user = SecUserManager.GetByUserId(userID); // load email credentials smtpHost = user.emailHost; int.TryParse(user.emailHostPort, out smtpPort); // recipients recipients = new string[] { recipient }; // build email body // .containerBox emailBody.Append("<div>"); emailBody.Append("<div>"); emailBody.Append("Claim Ruler Red Flag Alert.<br><br>"); emailBody.Append("Please correct the following issue as soon as possible: "); emailBody.Append(description + "with claim # " + claimid); emailBody.Append("</div>"); // paneContentInner emailBody.Append("</div>"); // containerBox password = Core.SecurityManager.Decrypt(user.emailPassword); Core.EmailHelper.sendEmail(user.Email, recipients, null, subject, emailBody.ToString(), null, user.emailHost, smtpPort, user.Email, password, true);//user.isSSL ?? }
protected void btnResetPassword_Click(object sender, EventArgs e) { // random password string password = Guid.NewGuid().ToString().Substring(0, 8); try { CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(Convert.ToInt32(hfUserId.Value)); // encrypt password user.Password = Core.SecurityManager.Encrypt(password); user = SecUserManager.Save(user); Core.EmailHelper.emailUserPasswordReset(user); lblSave.Text = "User password has been reset. New password sent to user via email."; } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblSave.Text = "Unable to reset password."; lblSave.Visible = true; } }
//public static SecUser SelectUser() //{ // var users = from x in DbContextHelper.DbContext.SecUsers // select x; // return users.Any() ? users.First() : new SecUser(); //} public static void Delete(SecUser user) { DbContextHelper.DbContext.DeleteObject(user); }
protected void btnSave_Click(object sender, EventArgs e) { lblError.Text = string.Empty; lblSave.Text = string.Empty; lblMessage.Text = string.Empty; lblError.Visible = false; lblSave.Visible = false; lblMessage.Visible = false; bool isnew = false; bool isError = false; CRM.Data.Entities.SecUser user = null; Page.Validate("register"); if (!Page.IsValid) return; // 2013-08-06 tortega int clientID = Core.SessionHelper.getClientId(); int roleID = Core.SessionHelper.getUserRoleId(); try { using (TransactionScope scope = new TransactionScope()) { if (hfUserId.Value == "0") { isnew = true; user = new CRM.Data.Entities.SecUser(); user.ClientID = clientID; } else { user = SecUserManager.GetByUserId(Convert.ToInt32(hfUserId.Value)); } // ** Add User ** // if (isnew) { bool userExist = SecUserManager.IsUserNameExist(txtUserName.Text.Trim()); //bool emailExist = SecUserManager.IsEmailExist(txtEmail.Text.Trim()); // 2013-08-06 tortega if (clientID > 0 && ClientManager.UsersLimitReached(clientID)) { throw new Exception("Maximum number of users reached."); } if (userExist) { throw new Exception("User Name already exists."); } } user.FirstName = txtFirstName.Text.Trim(); user.LastName = txtLastName.Text.Trim(); user.Email = txtEmail.Text; user.UserName = txtUserName.Text.Trim(); //user.Password = SecurityManager.Encrypt(txtPassWord.Text); user.RoleId = Convert.ToInt32(ddlRole.SelectedValue); user.Status = ddlStatus.SelectedValue == "1" ? true : false; user.Blocked = false; user.isViewAllClaims = cbxViewAllClaims.Checked; if (chkPassword.Checked == true || isnew) { user.Password = SecurityManager.Encrypt(txtPassWord.Text); } user.UserName = txtUserName.Text.Trim(); user.FirstName = txtFirstName.Text.Trim(); user.LastName = txtLastName.Text.Trim(); user.Email = txtEmail.Text; user.Status = ddlStatus.SelectedValue == "1" ? true : false; user.Blocked = user.Blocked; user.RoleId = Convert.ToInt32(ddlRole.SelectedValue); user = SecUserManager.Save(user); //clearControls(); scope.Complete(); if (isnew) lblSave.Text = "User account has been created. User credentials sent via email."; else lblSave.Text = "User account saved."; lblSave.Visible = true; btnResetPassword.Visible = true; } } catch (Exception ex) { isError = true; lblError.Text = ex.Message; lblError.Visible = true; Core.EmailHelper.emailError(ex); } finally { if (isnew && isError == false) { // email user account info Core.EmailHelper.emailUserCredentials(user); } } }
public static SecUser Save(SecUser secUser) { if (secUser.UserId == 0) { secUser.CreatedBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name); secUser.CreatedOn = DateTime.Now; secUser.CreatedMachineIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); DbContextHelper.DbContext.Add(secUser); } //secUser.UpdatedBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name); secUser.UpdatedMachineIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); secUser.UpdatedOn = DateTime.Now; DbContextHelper.DbContext.SaveChanges(); return secUser; }
public void DoAuthenticate(CRM.Data.Entities.SecUser user) { string url = null; string userData = null; List <int> roleActions = null; Session["UserId"] = user.UserId; Session["UserName"] = user.UserName; Session["RoleId"] = user.SecRole.RoleId.ToString(); // 201307-29 Session["ClientId"] = user.ClientID; if (user.Client.Count > 0) { Session["ClientShowTask"] = user.Client == null ? true : (user.Client.FirstOrDefault().isShowTasks ?? true); } else { Session["ClientShowTask"] = true; } userData = string.Format("{0}|{1}|{2} {3}|{4}", user.SecRole.RoleName, user.SecRole.RoleId, user.FirstName, user.LastName, user.Email); var ticket = new FormsAuthenticationTicket ( 1, user.UserId.ToString(), DateTime.Now, DateTime.Now.AddMinutes(120), true, userData, //(user.SecRole.RoleName + "|" + user.SecRole.RoleId.ToString()), FormsAuthentication.FormsCookiePath ); string encryptedTicket = FormsAuthentication.Encrypt(ticket); Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)); Session["rolePermission"] = resRolePermission = SecRoleModuleManager.getRolePermission(user.SecRole.RoleId).ToList(); // get role actions if (user.RoleId != (int)UserRole.Administrator) { using (ActionManager repository = new ActionManager()) { roleActions = repository.GetActions((int)user.ClientID, (int)user.RoleId); Session["roleActions"] = roleActions; } } //if (user.SecRole.RoleId == (int)UserRole.Adjuster) // url = "~/Protected/Intake/form.aspx"; //else if (Request.QueryString["url"] != null) { url = Request.QueryString["url"].ToString(); } else { url = FormsAuthentication.DefaultUrl; Session["Count"] = null; formatException(); setRulexception(); setGlobalSession(); Thread thread = new Thread(delegate() { workerObject.DoWork(); }); //ThreadPool.QueueUserWorkItem(new WaitCallback(workerObject.DoWork), leadView, testse); // workerThread = new Thread(workerObject.DoWork); thread.Start(); } Response.Redirect(url); }
protected void emailDocumentLink(string finalReportPath, string emailTo) { int userID = Core.SessionHelper.getUserId(); string bodyText = null; int leadID = Convert.ToInt32(Session["LeadIds"]); string password = null; int port = 0; string[] recipients = null; string subject = null; Leads lead = null; string encryptedQuery = null; System.Text.StringBuilder html = new System.Text.StringBuilder(); CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(userID); if (user != null && user.Email != null && user.emailHost != null && user.emailHostPort != null) { if (string.IsNullOrEmpty(emailTo)) { recipients = new string[] { user.Email } } ; else { recipients = emailTo.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); } lead = LeadsManager.GetByLeadId(leadID); if (lead != null) { encryptedQuery = Core.SecurityManager.EncryptQueryString(leadID.ToString()); subject = string.Format("{0} {1} wants to share {2} {3} Public Adjuster Claim File with you", user.FirstName, user.LastName, lead.ClaimantFirstName, lead.ClaimantLastName); html.Append("<table cellpadding=\"0\" cellspacing=\"0\" style=\"border-left:1px #b9e1fb solid;border-right:1px #b9e1fb solid;border-bottom:1px #b9e1fb solid;border-top:1px #b9e1fb solid;border-radius:0px 0px 4px 4px\" border=\"0\" align=\"center\">"); html.Append("<tbody><tr><td colspan=\"3\" height=\"36\"></td></tr>"); html.Append("<tr><td width=\"36\"></td>"); html.Append("<td width=\"454\" style=\"font-size:14px;color:#444444;font-family:'Open Sans','Lucida Grande','Segoe UI',Arial,Verdana,'Lucida Sans Unicode',Tahoma,'Sans Serif';border-collapse:collapse\" align=\"left\" valign=\"top\">"); html.Append(string.Format("{0} {1} invited you to a Claim Ruler Software shared file called \"{2} {3}.\"", user.FirstName, user.LastName, lead.ClaimantFirstName, lead.ClaimantLastName)); string css = "border-radius:3px;border-left:1px #18639a solid;font-size:16px;border-bottom:1px #0f568b solid;padding:14px 7px 14px 7px;border-top:1px #2270ab solid;display:block;max-width:210px;font-family:'Open Sans','lucida grande','Segoe UI',arial,verdana,'lucida sans unicode',tahoma,sans-serif;text-align:center;background-image:-webkit-gradient(linear,0% 0%,0% 100%,from(rgb(55,163,235)),to(rgb(33,129,207)));width:210px;text-decoration:none;color:white;border-right:1px #18639a solid;font-weight:600;margin:0px auto 0px auto;background-color:#33a0e8"; html.Append(string.Format("<br/><br/><center><a style=\"{0}\" href=\"{1}/Temp/{2}.pdf\">View Report</a></center>", css, ConfigurationManager.AppSettings["appURL"], leadID)); html.Append(string.Format("<br/><br/><center><a style=\"{0}\" href=\"{1}/Content/SharedDocuments.aspx?q={2}\">View Files</a></center></td>", css, ConfigurationManager.AppSettings["appURL"], encryptedQuery)); html.Append("<td width='36'></td></tr><tr><td colspan='3' height='36'></td></tr></tbody></table>"); port = Convert.ToInt32(user.emailHostPort); password = SecurityManager.Decrypt(user.emailPassword); bodyText = html.ToString(); Core.EmailHelper.sendEmail(user.Email, recipients, null, subject, bodyText, null, user.emailHost, port, user.Email, password, user.isSSL ?? false); } } }
private void batchEmailInvoices() { string[] attachments = null; StringBuilder bodyText = new StringBuilder(); int invoiceID = 0; int invoiceNumber = 0; List <string> invoicePaths = new List <string>(); int port = 0; string password = null; string[] recipients = null; string reportPath = null; string subject = null; CRM.Data.Entities.SecUser user = null; int userID = Core.SessionHelper.getUserId(); try { recipients = txtEmailTo.Text.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); user = SecUserManager.GetByUserId(userID); if (user != null && recipients.Length > 0) { port = Convert.ToInt32(user.emailHostPort); password = Core.SecurityManager.Decrypt(user.emailPassword); bodyText.Append(txtEmailText.Text); // add user signature bodyText.Append("<br><br>" + user.emailSignature ?? ""); foreach (GridViewRow row in gvInvoiceQ.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox cbxSelected = row.FindControl("cbxSelected") as CheckBox; if (cbxSelected.Checked) { invoiceID = (int)gvInvoiceQ.DataKeys[row.RowIndex].Values[0]; invoiceNumber = (int)gvInvoiceQ.DataKeys[row.RowIndex].Values[1]; reportPath = Core.ReportHelper.generateInvoicePDF(invoiceID); subject = string.Format("Invoice Number {0}", invoiceNumber); attachments = new string[] { reportPath }; Core.EmailHelper.sendEmail(user.Email, recipients, null, subject, bodyText.ToString(), attachments, user.emailHost, port, user.Email, password); cbxSelected.Checked = false; } } } lblMessage.Text = "Selected invoices have been emailed."; lblMessage.CssClass = "ok"; } } catch (Exception ex) { lblMessage.Text = "Selected invoices were not emailed."; lblMessage.CssClass = "error"; Core.EmailHelper.emailError(ex); } }
protected void loadData(string keyword) { int clientID = Core.SessionHelper.getClientId(); IQueryable <CRM.Data.Entities.Contact> contacts = null; if (keyword == null) { contacts = ContactManager.GetAll(clientID); } else { contacts = ContactManager.Search(keyword, clientID); } List <CRM.Data.Entities.Contact> contactList = contacts.ToList(); int userID = SessionHelper.getUserId(); CRM.Data.Entities.SecUser secUser = SecUserManager.GetByUserId(userID); string email = secUser.Email; string password = SecurityManager.Decrypt(secUser.emailPassword); string url = "https://" + secUser.emailHost + "/EWS/Exchange.asmx"; try { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Credentials = new WebCredentials(email, password); service.Url = new Uri(url); ContactsFolder contactsfolder = ContactsFolder.Bind(service, WellKnownFolderName.Contacts); int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50; ItemView view = new ItemView(int.MaxValue); view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ContactSchema.DisplayName); FindItemsResults <Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, view); foreach (Item item in contactItems) { if (item is Microsoft.Exchange.WebServices.Data.Contact) { item.Load(); Microsoft.Exchange.WebServices.Data.Contact contact = item as Microsoft.Exchange.WebServices.Data.Contact; CRM.Data.Entities.Contact newContact = new Data.Entities.Contact(); newContact.FirstName = contact.GivenName; newContact.LastName = contact.Surname; newContact.Email = contact.EmailAddresses[0].Address; newContact.DepartmentName = "Outlook"; bool exist = false; if (keyword == null || keyword[0] == newContact.Email[0]) { foreach (var con in contactList) { if (con.Email == newContact.Email) { exist = true; } } } if (!exist) { contactList.Add(newContact); } } } } catch (Exception ex) { } gvContact.DataSource = contactList; gvContact.DataBind(); }
private void notifyAdjuster(AdjusterMaster adjuster, StringBuilder claimList) { StringBuilder emailBody = new StringBuilder(); string password = null; string[] recipients = null; string smtpHost = null; int smtpPort = 0; string siteUrl = ConfigurationManager.AppSettings["siteUrl"].ToString(); string subject = "Claim Assignment Notification"; CRM.Data.Entities.SecUser user = null; string itsgHost = ConfigurationManager.AppSettings["smtpHost"].ToString(); string itsgHostPort = ConfigurationManager.AppSettings["smtpPort"].ToString(); string itsgEmail = ConfigurationManager.AppSettings["smtpEmail"].ToString(); string itsgEmailPassword = ConfigurationManager.AppSettings["smtpPassword"].ToString(); int.TryParse(itsgHostPort, out smtpPort); // get logged in user int userID = SessionHelper.getUserId(); //Convert.ToInt32(itsgHostPort); // get current user email info user = SecUserManager.GetByUserId(userID); // load email credentials smtpHost = user.emailHost; int.TryParse(user.emailHostPort, out smtpPort); // recipients recipients = new string[] { adjuster.email }; // build email body // .containerBox emailBody.Append("<div style=\"margin:auto;width:600px;border: 1px solid #DDDDE4; margin: auto;font-family: Tahoma, Arial,sans-serif;font-size: 12px;color: #808080;\">"); // .header //emailBody.Append("<div style=\"background-image:url(https://appv3.claimruler.com/images/email_header_small.jpg);background-repeat: no-repeat;background-size: 100% 100%;height:70px;\"></div>"); emailBody.Append("<div><img src=\"http://app.claimruler.com/images/email_header_small.jpg\"></image></div>"); // .paneContentInner emailBody.Append("<div style=\"margin: 20px;\">"); emailBody.Append("Hi " + adjuster.adjusterName + "!<br><br>"); emailBody.Append("Your firm uses Claim Ruler software for claims management and the following claim(s) have been assigned to you.<br><br>"); emailBody.Append("Please review claim(s) right away to begin handling the file(s). Time is of the essence!<br><br>"); emailBody.Append("<table style=\"width:550px;\">"); emailBody.Append(string.Format("<tr align=\"center\"><th scope=\"col\">{0}</th><th scope=\"col\">{1}</th><th scope=\"col\">{2}</th></tr>", "Insured Name", "Adjuster Claim #", "Insurer Claim #")); // claim list emailBody.Append(claimList.ToString()); // end email body emailBody.Append("</table>"); emailBody.Append(string.Format("<p><a href=\"{0}/login.aspx\">Please click here to access Claim Ruler.</a></p>", siteUrl)); emailBody.Append("<br>Thank you."); emailBody.Append("</div>"); // inner containerBox emailBody.Append("</div>"); // paneContentInner emailBody.Append("</div>"); // containerBox //Core.EmailHelper.sendEmail(user.Email, recipients, null, "Claim Assignment Notification", emailBody.ToString(), null, user.emailHost, smtpPort, smtpEmail, smtpPassword, true); password = Core.SecurityManager.Decrypt(user.emailPassword); //Core.EmailHelper.sendEmail(user.Email, recipients, null, subject, emailBody.ToString(), null, user.emailHost, smtpPort, user.Email, password, user.isSSL ?? true); Core.EmailHelper.sendEmail(user.Email, recipients, null, subject, emailBody.ToString(), null, itsgHost, Convert.ToInt32(itsgHostPort), itsgEmail, itsgEmailPassword); }
protected void btnSend_Click(object sender, EventArgs e) { string[] attachments = null; ClaimComment comment = null; string emailTo = txtEmailTo.Text.Trim().Replace(",", ";"); string emailBody = null; string[] cc = null; string cc_list = null; string decryptedPassword = null; ArrayList documentArray = null; bool isSSL = true; int leadID = 0; int port = 0; string[] recipients = emailTo.Split(';'); string subject = null; CRM.Data.Entities.SecUser user = null; Page.Validate("email"); if (!Page.IsValid) { return; } // get user information user = SecUserManager.GetByUserId(SessionHelper.getUserId()); if (user == null) { clearFields(); return; } // decrypt user password decryptedPassword = Core.SecurityManager.Decrypt(user.emailPassword); // email CC if (!string.IsNullOrEmpty(txtEmailCC.Text)) { cc_list = txtEmailCC.Text.Replace(",", ";"); cc = cc_list.Split(';'); } // get attachments if (lbxDocuments != null && lbxDocuments.Items != null && lbxDocuments.Items.Count > 0) { documentArray = new ArrayList(); foreach (ListItem item in lbxDocuments.Items) { if (item.Selected) { string documentPath = appPath + "/" + item.Value; documentArray.Add(documentPath); } } attachments = documentArray.ToArray(typeof(string)) as string[]; } // add to comments int.TryParse(user.emailHostPort, out port); emailBody = string.Format("<div>{0}</div><div>{1}</div>", txtEmailText.Text.Trim(), txtSignature.Text.Trim()); subject = txtEmailSubject.Text.Trim(); //isSSL = user.isSSL ?? true; //string smtpHost = ConfigurationManager.AppSettings["smtpHost"].ToString(); //int smtpPort = ConfigurationManager.AppSettings["smtpPort"] == null ? 25 : Convert.ToInt32(ConfigurationManager.AppSettings["smtpPort"]); //string smtpEmail = ConfigurationManager.AppSettings["smtpEmail"].ToString(); //string smtpPassword = ConfigurationManager.AppSettings["smtpPassword"].ToString(); try { // Core.EmailHelper.sendEmail(txtEmailFrom.Text, recipients, cc, subject, emailBody, attachments, smtpHost, smtpPort, smtpEmail, smtpPassword, isSSL); userID = SessionHelper.getUserId(); CRM.Data.Entities.SecUser secUser = SecUserManager.GetByUserId(userID); string emailaddress = secUser.Email; string password = SecurityManager.Decrypt(secUser.emailPassword); string url = "https://" + secUser.emailHost + "/EWS/Exchange.asmx"; ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Credentials = new WebCredentials(emailaddress, password); service.Url = new Uri(url); EmailMessage email = new EmailMessage(service); foreach (var recipient in recipients) { if (!string.IsNullOrEmpty(recipient)) { email.ToRecipients.Add(recipient); } } email.Subject = subject; email.Body = new MessageBody(emailBody); foreach (var filename in attachments) { if (!string.IsNullOrEmpty(filename)) { email.Attachments.AddFileAttachment(filename); } } email.SendAndSaveCopy(); comment = new ClaimComment(); comment.ClaimID = this.claimID; comment.CommentDate = DateTime.Now; comment.CommentText = string.Format("Sent Email:<br/>To: {0}<br/>Subject: {1}<br/>{2}", txtEmailTo.Text.Trim(), txtEmailSubject.Text.Trim(), txtEmailText.Text.Trim()); comment.IsActive = true; comment.UserId = this.userID; ClaimCommentManager.Save(comment); clearFields(); lblMessage.Text = "Email sent successfully."; lblMessage.CssClass = "ok"; } catch (Exception ex) { lblMessage.Text = "Incorrect Email Settings. Email not sent."; lblMessage.CssClass = "error"; Core.EmailHelper.emailError(ex); } }
protected void btnCreateCarrierAccount_Click(object sender, EventArgs e) { int clientID = 0; int contactID = 0; Contact contact = null; string newUserName = null; string password = null; CRM.Data.Entities.SecUser newUserAccount = null; CRM.Data.Entities.SecUser user = null; lblMessage.Text = string.Empty; lblMessage.CssClass = string.Empty; Page.Validate("Account"); if (!Page.IsValid) { return; } clientID = SessionHelper.getClientId(); newUserName = txtUserName.Text.Trim(); // check username is not taken if (SecUserManager.IsUserNameExist(newUserName)) { lblMessage.Text = "User Name " + newUserName + " is already taken."; lblMessage.CssClass = "error"; return; } // initialize user object user = new CRM.Data.Entities.SecUser(); user.UserName = newUserName; user.FirstName = txtFirstName.Text; user.LastName = txtLastName.Text; user.Status = true; user.isSSL = true; // assign client for this user user.ClientID = clientID; // attach carrier to user user.CarrierID = this.carrierID; user.CreatedBy = Core.SessionHelper.getUserId(); user.CreatedOn = DateTime.Now; user.Email = txtContactEmail.Text.Trim(); // assign selected role user.RoleId = Convert.ToInt32(ddlClientRoles.SelectedValue); // random password password = Guid.NewGuid().ToString().Substring(0, 8); // encrypt password user.Password = Core.SecurityManager.Encrypt(password); try { using (TransactionScope scope = new TransactionScope()) { // add new user account newUserAccount = SecUserManager.Save(user); // associate new user account with contact contactID = Convert.ToInt32(ViewState["ContactID"]); contact = ContactManager.Get(contactID); contact.UserID = newUserAccount.UserId; ContactManager.Save(contact); scope.Complete(); } // email adjuster about newly created account Core.EmailHelper.emailUserCredentials(newUserAccount); lblMessage.Text = string.Format("User Account '{0}' was created and credentials were emailed to the user.", newUserName); lblMessage.CssClass = "ok"; // hide create account button this.btnShowCreateAccount.Visible = false; this.btnCreateCarrierAccount.Visible = false; } catch (Exception ex) { lblMessage.Text = "Unable to create user account."; lblMessage.CssClass = "error"; Core.EmailHelper.emailError(ex); } }
protected void btnSave_Click(object sender, EventArgs e) { int clientID = 0; Client client = null; CRM.Data.Entities.SecUser user = null; bool isNew = false; int invoiceSettingID = 0; int userID = 0; Page.Validate("Client"); if (!Page.IsValid) return; if (int.TryParse(hfclientid.Value, out clientID) && clientID > 0) { // update existing client = ClientManager.Get(clientID); } else { // new user client = new Client(); // default value client.InactivityDays = 30; isNew = true; } if (client != null) { try { client.ClientTypeID = Convert.ToInt32(ddlClientType.SelectedValue); client.FirstName = txtFirstName.Text.Trim(); client.LastName = txtLastName.Text.Trim(); client.BusinessName = txtBusinessName.Text.Trim(); client.StreetAddress1 = txtAddress.Text.Trim(); client.CityId = Convert.ToInt32(ddlCity.SelectedValue); client.StateId = Convert.ToInt32(ddlState.SelectedValue); client.ZipCode = ddlZipCode.SelectedValue; client.PrimaryPhoneNo = txtPhone.Text.Trim(); client.SecondaryPhoneNo = txtFaxNumber.Text.Trim(); client.PrimaryEmailId = txtEmail.Text.Trim(); client.Active = 1; client.maxUsers = string.IsNullOrEmpty(txtNumberUsers.Text) ? 1 : Convert.ToInt32(txtNumberUsers.Text); client.FeePerContract = string.IsNullOrEmpty(txtFeePerContract.Text) ? 1 : Convert.ToDecimal(txtFeePerContract.Text); client.FederalIDNo = txtFederalTaxID.Text.Trim(); client.MaxLeads = Convert.ToInt32(string.IsNullOrEmpty(txtMaxLeads.Text) ? "0" : txtMaxLeads.Text); client.isTrial = cbxTrial.Checked; client.isShowTasks = cbxShowTasks.Checked; client.InactivityDays = string.IsNullOrEmpty(txtInactivityPeriod.Text) ? 0 : Convert.ToInt32(txtInactivityPeriod.Text); // imap settings client.imapHost = txtImapHost.Text.Trim(); client.imapHostPort = string.IsNullOrEmpty(txtImapHostPort.Text) ? 0 : Convert.ToInt32(txtImapHostPort.Text); client.imapHostUseSSL = cbxImapUseSSL.Checked; // invoice billing settings invoiceSettingID = Convert.ToInt32(ddlInvoiceSetting.SelectedValue); if (invoiceSettingID > 0) client.InvoiceSettingID = invoiceSettingID; client.InvoiceContingencyFee = txtContingencyFee.Value == null ? 0 : Convert.ToDecimal(txtContingencyFee.Value); // save client clientID = ClientManager.Save(client); if (isNew) { try { user = new CRM.Data.Entities.SecUser(); user.UserName = txtUserName.Text.Trim(); user.FirstName = txtFirstName.Text.Trim(); user.LastName = txtLastName.Text.Trim(); user.Status = true; user.RoleId = (int)UserRole.Client; user.Email = txtEmail.Text.Trim(); user.Password = SecurityManager.Encrypt(txtUserPassword.Text.Trim()); user.CreatedOn = DateTime.Now; user.CreatedBy = 1; user.UpdatedOn = DateTime.Now; user.UpdatedBy = 1; user.ClientID = clientID; CRM.Data.Entities.SecUser newUser = SecUserManager.Save(user); client = ClientManager.Get(clientID); if (client != null) { client.UserId = newUser.UserId; ClientManager.Save(client); } } catch (Exception ex) { lblMessage.Text = "Unable to create new user account."; lblMessage.CssClass = "error"; Core.EmailHelper.emailError(ex); } } else { // update user if (int.TryParse(hfuserid.Value, out userID) && userID > 0) { user = SecUserManager.GetByUserId(userID); if (user != null) { user.FirstName = txtFirstName.Text.Trim(); user.LastName = txtLastName.Text.Trim(); if (!string.IsNullOrEmpty(txtUserPassword.Text)) user.Password = SecurityManager.Encrypt(txtUserPassword.Text.Trim()); SecUserManager.Save(user); } } } lblMessage.Text = "Client changes saved."; lblMessage.CssClass = "ok"; } catch (Exception ex) { lblMessage.Text = "Unable to create new user account."; lblMessage.CssClass = "error"; Core.EmailHelper.emailError(ex); } } // if (client != null) { // clear after edit //Session.Remove("EditClientId"); //Response.Redirect("~/Protected/Admin/ClientList.aspx"); }
private void FillForm() { string photoPath = null; int userId = Session["UID"] != null?Convert.ToInt32(Session["UID"]) : 0; int roleID = SessionHelper.getUserRoleId(); if (userId > 0) { hfUserId.Value = userId.ToString(); lblheading.Text = "Edit User Details"; chkPassword.Enabled = true; btnResetPassword.Visible = true; } else { lblheading.Text = "New User"; chkPassword.Visible = false; btnResetPassword.Visible = false; } bindRole(); if (userId > 0) { // update user CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(Convert.ToInt32(userId)); if (user.UserId > 0 && user.UserName != null) { txtFirstName.Text = user.FirstName; txtLastName.Text = user.LastName; txtEmail.Text = user.Email; txtUserName.Text = user.UserName; txtPassWord.Text = SecurityManager.Decrypt(user.Password); ViewState["Password"] = txtPassWord.Text; txtPassWord.Attributes.Add("value", "12345"); txtPassWord.Enabled = false; txtRePassWord.Text = SecurityManager.Decrypt(user.Password); txtRePassWord.Attributes.Add("value", "12345"); txtRePassWord.Enabled = false; cbxViewAllClaims.Checked = user.isViewAllClaims ?? false; // disable role DDL when client is editing his own client id if (roleID == (int)UserRole.Client && user.RoleId == (int)UserRole.Client) { ddlRole.Enabled = false; ddlRole.Items.Add(new ListItem("Client", user.RoleId.ToString())); } else { ddlRole.Enabled = true; } ddlRole.SelectedValue = user.RoleId.ToString(); if (user.Status.ToString() == "True") { ddlStatus.SelectedValue = "1"; } else { ddlStatus.SelectedValue = "0"; } if (user.ClientID != null) { ddlClient.SelectedValue = user.ClientID.ToString(); } userPhoto.ImageUrl = Core.Common.getUserPhotoURL(user.UserId); //txtEmailSignature.Text = user.emailSignature; } if (user.RoleId == 1) { CRM.Data.Entities.SecUser loginUser = SecUserManager.GetByUserId(Convert.ToInt32(Session["UserId"])); ddlStatus.Enabled = false; txtUserName.Enabled = false; } } }
protected void btnDocumentsSearch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtKeyword.Text)) { lblErrorMSg.Visible = true; } else { lblErrorMSg.Visible = false; int userID = SessionHelper.getUserId(); CRM.Data.Entities.SecUser secUser = SecUserManager.GetByUserId(userID); string email = secUser.Email; string password = SecurityManager.Decrypt(secUser.emailPassword); string url = "https://" + secUser.emailHost + "/EWS/Exchange.asmx"; try { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Credentials = new WebCredentials(email, password); service.Url = new Uri(url); ItemView view = new ItemView(int.MaxValue); Microsoft.Exchange.WebServices.Data.SearchFilter searchFilter = new Microsoft.Exchange.WebServices.Data.SearchFilter.ContainsSubstring(ItemSchema.Body, txtKeyword.Text); instanceResults = service.FindItems(WellKnownFolderName.Inbox, searchFilter, view); DataTable table = GetTable(); foreach (var item in instanceResults.Items) { item.Load(); //Console.Clear(); EmailMessage msg = item as EmailMessage; DataRow row = table.NewRow(); string to = string.Empty; foreach (var rec in msg.ToRecipients) { to = to + rec.Address + ";"; } row["Subject"] = msg.Subject; string body = ExtractHtmlInnerText(msg.Body); if (body.Length > 2000) { body = body.Substring(0, 2000); } row["Body"] = "From :" + msg.From.Address + "\nTo :" + to + "\nSubject: " + msg.Subject + "\n" + body; row["No.of Attachments"] = msg.Attachments.Count.ToString(); row["Date"] = msg.DateTimeReceived.Date.ToShortDateString(); table.Rows.Add(row); } gvSearchResult.DataSource = table; gvSearchResult.DataBind(); pnlSearchResult.Visible = true; } catch (Exception ex) { lblErrorMSg.Text = "Incorrect Email Settings"; lblErrorMSg.Visible = true; } } }
protected void btnSave_Click(object sender, EventArgs e) { lblError.Text = string.Empty; lblSave.Text = string.Empty; lblMessage.Text = string.Empty; lblError.Visible = false; lblSave.Visible = false; lblMessage.Visible = false; bool isnew = false; bool isError = false; CRM.Data.Entities.SecUser user = null; Page.Validate("register"); if (!Page.IsValid) { return; } // 2013-08-06 tortega int clientID = Core.SessionHelper.getClientId(); int roleID = Core.SessionHelper.getUserRoleId(); try { using (TransactionScope scope = new TransactionScope()) { if (hfUserId.Value == "0") { isnew = true; user = new CRM.Data.Entities.SecUser(); user.ClientID = clientID; } else { user = SecUserManager.GetByUserId(Convert.ToInt32(hfUserId.Value)); } // ** Add User ** // if (isnew) { bool userExist = SecUserManager.IsUserNameExist(txtUserName.Text.Trim()); //bool emailExist = SecUserManager.IsEmailExist(txtEmail.Text.Trim()); // 2013-08-06 tortega if (clientID > 0 && ClientManager.UsersLimitReached(clientID)) { throw new Exception("Maximum number of users reached."); } if (userExist) { throw new Exception("User Name already exists."); } } user.FirstName = txtFirstName.Text.Trim(); user.LastName = txtLastName.Text.Trim(); user.Email = txtEmail.Text; user.UserName = txtUserName.Text.Trim(); //user.Password = SecurityManager.Encrypt(txtPassWord.Text); user.RoleId = Convert.ToInt32(ddlRole.SelectedValue); user.Status = ddlStatus.SelectedValue == "1" ? true : false; user.Blocked = false; user.isViewAllClaims = cbxViewAllClaims.Checked; if (chkPassword.Checked == true || isnew) { user.Password = SecurityManager.Encrypt(txtPassWord.Text); } user.UserName = txtUserName.Text.Trim(); user.FirstName = txtFirstName.Text.Trim(); user.LastName = txtLastName.Text.Trim(); user.Email = txtEmail.Text; user.Status = ddlStatus.SelectedValue == "1" ? true : false; user.Blocked = user.Blocked; user.RoleId = Convert.ToInt32(ddlRole.SelectedValue); user = SecUserManager.Save(user); //clearControls(); scope.Complete(); if (isnew) { lblSave.Text = "User account has been created. User credentials sent via email."; } else { lblSave.Text = "User account saved."; } lblSave.Visible = true; btnResetPassword.Visible = true; } } catch (Exception ex) { isError = true; lblError.Text = ex.Message; lblError.Visible = true; Core.EmailHelper.emailError(ex); } finally { if (isnew && isError == false) { // email user account info Core.EmailHelper.emailUserCredentials(user); } } }
public List<string> getEmailData(int claimId, int BusinessRuleID) { List<string> emailData = new List<string>(); string adjusterEmail = ""; int adjusterId = 0; int superVisorId = 0; string adjusterClaimNumber = ""; string dateRecieved = ""; int ruleId = 0; string businessDescription = ""; string redFlagName = ""; string insuredName = ""; string adjusterName = ""; ClaimManager ClaimManagerObj = new ClaimManager(); Claim claimObj = new Claim(); claimObj = ClaimManagerObj.Get(claimId); if (claimObj != null && claimObj.AdjusterID != null) { adjusterId = Convert.ToInt32(claimObj.AdjusterID); } if (claimObj != null && claimObj.InsurerClaimNumber != null) { adjusterClaimNumber = claimObj.InsurerClaimNumber; } if (claimObj != null && claimObj.DateOpenedReported != null) { dateRecieved = Convert.ToString(claimObj.DateOpenedReported); } AdjusterMaster adjusterMasterObj = new AdjusterMaster(); if (claimObj != null) { adjusterMasterObj = claimObj.AdjusterMaster; } if (adjusterMasterObj != null && adjusterMasterObj.email != null) { adjusterEmail = Convert.ToString(adjusterMasterObj.email); } if (adjusterMasterObj != null && adjusterMasterObj.adjusterName != null) { adjusterName = Convert.ToString(adjusterMasterObj.adjusterName); } if (adjusterMasterObj != null && adjusterMasterObj.SupervisorID != null) { superVisorId = Convert.ToInt32(adjusterMasterObj.SupervisorID); } CRM.Data.Entities.SecUser secUserObj = new CRM.Data.Entities.SecUser(); secUserObj = getSecUser(superVisorId); insuredName = claimObj.LeadPolicy.Leads.insuredName; BusinessRuleManager BusinessRuleManagerObj = new BusinessRuleManager(); BusinessRule BusinessRuleObj = new BusinessRule(); BusinessRuleObj = BusinessRuleManagerObj.GetBusinessRule(BusinessRuleID); if (BusinessRuleObj.RuleID != null) { ruleId = Convert.ToInt32(BusinessRuleObj.RuleID); }; businessDescription = BusinessRuleObj.Description; CRM.Data.Entities.Rule ruleObj = new CRM.Data.Entities.Rule(); ruleObj = BusinessRuleManagerObj.GetRule(ruleId); redFlagName = ruleObj.RuleName; string encryptedClaimNumber = Core.SecurityManager.EncryptQueryString(claimId.ToString()); emailData.Add(adjusterEmail); emailData.Add(adjusterName); emailData.Add(secUserObj.Email); emailData.Add(secUserObj.UserName); emailData.Add(adjusterClaimNumber); emailData.Add(dateRecieved); emailData.Add(businessDescription); emailData.Add(redFlagName); emailData.Add(insuredName); emailData.Add(encryptedClaimNumber); return emailData; }
protected void Page_Load(object sender, EventArgs e) { // access master page from nested master page Protected.ClaimRuler masterPage = Master.Master as Protected.ClaimRuler; // check user permission //masterPage.checkPermission(); clientID = SessionHelper.getClientId(); // get current lead leadID = SessionHelper.getLeadId(); // get current lead id claimID = SessionHelper.getClaimID(); // get current user userID = SessionHelper.getUserId(); // set directory where client can upload pictures for signature txtSignature.UploadedFilesDirectory = appPath + "/clientLogo/" + clientID; if (!Page.IsPostBack) { bindData(); userID = SessionHelper.getUserId(); CRM.Data.Entities.SecUser secUser = SecUserManager.GetByUserId(userID); string email = secUser.Email; string password = SecurityManager.Decrypt(secUser.emailPassword); string url = "https://" + secUser.emailHost + "/EWS/Exchange.asmx"; try { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Credentials = new WebCredentials(email, password); service.Url = new Uri(url); ContactsFolder contactsfolder = ContactsFolder.Bind(service, WellKnownFolderName.Contacts); int numItems = contactsfolder.TotalCount < 50 ? contactsfolder.TotalCount : 50; ItemView view = new ItemView(int.MaxValue); view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ContactSchema.DisplayName); FindItemsResults <Item> contactItems = service.FindItems(WellKnownFolderName.Contacts, view); DataTable table = new DataTable(); table.Columns.Add("FirstName", typeof(string)); table.Columns.Add("LastName", typeof(string)); table.Columns.Add("CompanyName", typeof(string)); table.Columns.Add("Email", typeof(string)); table.Columns.Add("ContactType", typeof(string)); foreach (GridRecord crow in contractGrid.Rows) { DataRow row = table.NewRow(); row[0] = crow.Items[0].Text; row[1] = crow.Items[1].Text; //row[2] = crow.Cells[2].Text; row[3] = crow.Items[3].Text; row[4] = crow.Items[4].Text; table.Rows.Add(row); } foreach (Item item in contactItems) { if (item is Microsoft.Exchange.WebServices.Data.Contact) { item.Load(); Microsoft.Exchange.WebServices.Data.Contact contact = item as Microsoft.Exchange.WebServices.Data.Contact; DataRow row = table.NewRow(); row[0] = contact.GivenName; row[1] = contact.Surname; row[3] = contact.EmailAddresses[0].Address; row[4] = "Outlook"; table.Rows.Add(row); } } contractGrid.DataSourceID = null; contractGrid.Columns.Clear(); contractGrid.DataBind(); contractGrid.DataSource = table; contractGrid.DataBind(); } catch (Exception ex) { } } }
public CRM.Data.Entities.SecUser getSecUser(int superVisorId) { string connectionString = ConfigurationManager.ConnectionStrings["ClaimRuler"].ConnectionString; string str_query = @"SELECT * FROM SecUser WHERE UserId = @userId"; CRM.Data.Entities.SecUser SecUserObj = new CRM.Data.Entities.SecUser(); using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand(str_query, conn)) { cmd.Parameters.AddWithValue("@userId", superVisorId); conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { if (reader["Email"] != null) { SecUserObj.Email = Convert.ToString(reader["Email"]); } if (reader["UserName"] != null) { SecUserObj.UserName = Convert.ToString(reader["UserName"]); } } conn.Close(); } return SecUserObj; }
protected void bindData() { //AppraiserMaster appraiser = null; Claim claim = null; //List<LeadContact> contacts = null; List <DocumentList> attachments = null; //ContractorMaster contractor = null; //List<SecUser> users = null; Leads lead = null; //Data.UmpireMaster umpire = null; // get email for user sending email CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(userID); if (user != null) { txtEmailFrom.Text = user.Email; txtEmailCC.Text = user.Email; txtSignature.Text = user.emailSignature ?? ""; } claim = ClaimsManager.Get(this.claimID); if (claim != null) { attachments = new List <DocumentList>(); lead = claim.LeadPolicy.Leads; // build subject line txtEmailSubject.Text = string.Format("{0} Claim #: {1}", lead.policyHolderName, claim.AdjusterClaimNumber); // load legacy documents List <LeadsDocument> documents = LeadsUploadManager.getLeadsDocumentByLeadID((int)claim.LeadPolicy.LeadId); if (documents != null && documents.Count > 0) { foreach (LeadsDocument x in documents) { DocumentList attachment = new DocumentList(); attachment.DocumentName = x.Description; attachment.DocumentPath = string.Format("LeadsDocument/{0}/{1}/{2}", x.LeadId, x.LeadDocumentId, // document id x.DocumentName); // document file name attachments.Add(attachment); } } // load claim documents List <ClaimDocument> claimDocuments = ClaimDocumentManager.GetAll(this.claimID); if (claimDocuments != null && claimDocuments.Count > 0) { foreach (ClaimDocument x in claimDocuments) { DocumentList attachment = new DocumentList(); attachment.DocumentName = x.Description; attachment.DocumentPath = string.Format("ClaimDocuments/{0}/{1}/{2}", x.ClaimID, x.ClaimDocumentID, // document id x.DocumentName); // document file name attachments.Add(attachment); } } lbxDocuments.DataSource = attachments; lbxDocuments.DataBind(); //// load legacy contacts //contacts = LeadContactManager.GetContactByLeadID(leadID); //// add adjusters to contact list //if (claim.AdjusterMaster != null) // addToContactList(claim.AdjusterMaster.AdjusterName, claim.AdjusterMaster.email, contacts); //// add appraiser to contact list //if (lead.AppraiserID != null) { // appraiser = AppraiserManager.Get((int)lead.AppraiserID); // contacts.Add(new LeadContact { // Email = appraiser.Email, // ContactName = appraiser.AppraiserName // }); //} //// add contractor to contact list //if (lead.ContractorID != null) { // contractor = ContractorManager.Get((int)lead.ContractorID); // contacts.Add(new LeadContact { // Email = lead.ContractorMaster.Email, // ContactName = lead.ContractorMaster.ContractorName // }); //} //// add umpire to contact list //if (lead.UmpireID != null) { // umpire = UmpireManager.Get((int)lead.UmpireID); // contacts.Add(new LeadContact { // Email = lead.UmpireMaster.Email, // ContactName = lead.UmpireMaster.UmpireName // }); //} // add users 2013-12-12 //users = SecUserManager.GetUsers(clientID); //if (users != null && users.Count > 0) { // users.ForEach(x => // contacts.Add(new LeadContact { // Email = x.Email, // ContactName = x.FirstName ?? "" + " " + x.LastName ?? "" // })); //} } //lbxContacts.DataSource = contacts; //lbxContacts.DataBind(); }
protected void btnCreateAccount_Click(object sender, EventArgs e) { AdjusterMaster adjuster = null; int adjusterID = 0; int clientID = 0; string newUserName = null; string password = null; //CRM.Data.Entities.SecUser newUserAccount = null; CRM.Data.Entities.SecUser user = null; // prepare user name newUserName = string.Format("{0}.{1}", txtFirstName.Text.ToLower(), txtLastName.Text.ToLower()); // check username is not taken if (SecUserManager.IsUserNameExist(newUserName)) { lblError.Text = "User Name " + newUserName + " is already taken."; return; } try { using (TransactionScope scope = new TransactionScope()) { // add new user account // initialize user object user = new CRM.Data.Entities.SecUser(); user.UserName = newUserName; user.FirstName = txtFirstName.Text; user.LastName = txtLastName.Text; user.Status = true; user.Blocked = false; //user.isSSL = true; // assign client for this user clientID = Core.SessionHelper.getClientId(); if (clientID > 0) user.ClientID = clientID; user.CreatedBy = Core.SessionHelper.getUserId(); user.CreatedOn = DateTime.Now; user.Email = txtEmail.Text; // assign adjuster role..well now they can select what ever role they want user.RoleId = Convert.ToInt32(ddlRole.SelectedValue); //38; //(int)UserRole.Adjuster; user.isViewAllClaims = cbxViewAllClaims.Checked; // random password password = Guid.NewGuid().ToString().Substring(0, 8); // encrypt password user.Password = Core.SecurityManager.Encrypt(password); user = SecUserManager.Save(user); //int.TryParse(hdId.Value, out adjusterID); adjusterID = AdjusterManager.GetAdjusterIdForNewUser(); //added new to get the last adjuster created n if (user != null && adjusterID > 0) { // get adjuster adjuster = AdjusterManager.GetAdjusterId(adjusterID); if (adjuster != null) { // assign new user id to adjuster adjuster.userID = user.UserId; // update adjuster AdjusterManager.Save(adjuster); // email adjuster about newly created account if (!string.IsNullOrEmpty(adjuster.email)) newAccountNotification(adjuster, user); // hide create account button btnCreateAccount.Visible = false; } } scope.Complete(); lblSave.Text = "User account for adjuster has been created."; lblSave.Visible = true; } } catch (Exception ex) { lblError.Visible = true; lblError.Text = "Unable to create user account."; Core.EmailHelper.emailError(ex); } }
//EMAIL TO: Specified User private void notifySpecifiedUser(AdjusterMaster adjuster, ClaimService service, Claim myClaim) { StringBuilder emailBody = new StringBuilder(); string password = null; string[] recipients = null; string smtpHost = null; int smtpPort = 0; string siteUrl = ConfigurationManager.AppSettings["siteUrl"].ToString(); string insuredName = Session["InsuredName"].ToString(); string subject = "Claim # " + myClaim.InsurerClaimNumber + ", Please Read Claim Note, Claim Ruler Note for : " + insuredName; CRM.Data.Entities.SecUser user = null; string itsgHost = ConfigurationManager.AppSettings["smtpHost"].ToString(); string itsgHostPort = ConfigurationManager.AppSettings["smtpPort"].ToString(); string itsgEmail = ConfigurationManager.AppSettings["smtpEmail"].ToString(); string itsgEmailPassword = ConfigurationManager.AppSettings["smtpPassword"].ToString(); string EmailService = ddlInvoiceServiceType.SelectedItem.Text; string EmailActivity = ddlActivity.SelectedItem.Text; string EmailDescription = txtServiceDescription.Text; string EmailInternal = txtMyComments.Text; string EmailQuantity = txtServiceQty.Text; string EmailDate = txtServiceDate.Text; string userName = SessionHelper.getUserName(); int.TryParse(itsgHostPort, out smtpPort); // get logged in user int userID = SessionHelper.getUserId(); //Convert.ToInt32(itsgHostPort); // get current user email info user = SecUserManager.GetByUserId(userID); // load email credentials smtpHost = user.emailHost; int.TryParse(user.emailHostPort, out smtpPort); // recipients recipients = new string[] { txtEmailTo.Text }; // build email body // .containerBox emailBody.Append("<div style=\"margin:auto;width:600px;border: 1px solid #DDDDE4; margin: auto;font-family: Tahoma, Arial,sans-serif;font-size: 12px;color: #808080;\">"); // .header //emailBody.Append("<div style=\"background-image:url(https://appv3.claimruler.com/images/email_header_small.jpg);background-repeat: no-repeat;background-size: 100% 100%;height:70px;\"></div>"); //emailBody.Append("<div><img src=\"http://app.claimruler.com/images/email_header_small.jpg\"></image></div>"); // .paneContentInner emailBody.Append("<div style=\"margin: 20px;\">"); emailBody.Append("Hi " + adjuster.adjusterName + ",<br><br>"); emailBody.Append("The following activity was just logged on Claim # " + myClaim.InsurerClaimNumber + " for Insured: " + insuredName + "<br><br><br>"); emailBody.Append("<table >"); emailBody.Append("<tr> "); emailBody.Append("<td align=\"left\"><b>Service:</b></td><td align=\"left\"> " + EmailService + "</td>"); emailBody.Append("</tr>"); // emailBody.Append("</table><br><br>"); emailBody.Append("<tr>"); emailBody.Append("<td align=\"left\"><b>Activity:</b></td><td align=\"left\"> " + EmailActivity + "</td>"); emailBody.Append("</tr>"); emailBody.Append("<tr> "); emailBody.Append("<td align=\"left\"><b>Description:</b></td><td align=\"left\"> " + EmailDescription + "</td>"); emailBody.Append("</tr>"); emailBody.Append("<tr> "); emailBody.Append("<td align=\"left\"><b>Internal Comments:</b></td><td align=\"left\"> " + EmailInternal + "</td>"); emailBody.Append("</tr>"); emailBody.Append("<tr></tr>"); emailBody.Append("<tr> "); emailBody.Append("<td align=\"left\"><b>Adjuster:</b></td><td align=\"left\"> " + adjuster.adjusterName + "</td>"); emailBody.Append("</tr>"); emailBody.Append("<tr> "); emailBody.Append("<td align=\"left\"><b>User Name:</b></td><td align=\"left\"> " + userName + "</td>"); emailBody.Append("</tr>"); emailBody.Append("<tr> "); emailBody.Append("<td align=\"left\"><b>Service Date:</b></td><td align=\"left\"> " + EmailDate + "</td>"); emailBody.Append("</tr>"); emailBody.Append("<tr> "); emailBody.Append("<td align=\"left\"><b>Timer Quantity:</b></td><td align=\"left\"> " + EmailQuantity + "</td>"); emailBody.Append("</tr>"); emailBody.Append("</table ><br><br>"); emailBody.Append("</div>"); // inner containerBox emailBody.Append("</div>"); // paneContentInner emailBody.Append("</div>"); // containerBox //Core.EmailHelper.sendEmail(user.Email, recipients, null, "Claim Assignment Notification", emailBody.ToString(), null, user.emailHost, smtpPort, smtpEmail, smtpPassword, true); password = Core.SecurityManager.Decrypt(user.emailPassword); //Core.EmailHelper.sendEmail(user.Email, recipients, null, subject, emailBody.ToString(), null, user.emailHost, smtpPort, user.Email, password, user.isSSL ?? true); Core.EmailHelper.sendEmail(itsgEmail, recipients, null, subject, emailBody.ToString(), null, itsgHost, Convert.ToInt32(itsgHostPort), itsgEmail, itsgEmailPassword); }
protected void btnSave_Click(object sender, EventArgs e) { decimal balance = 0; CRM.Data.Entities.Contact contact = null; int clientID = Core.SessionHelper.getClientId(); int contactID = 0; Page.Validate("contact"); if (!Page.IsValid) { return; } contactID = Convert.ToInt32(hdId.Value); if (contactID == 0) { contact = new CRM.Data.Entities.Contact(); contact.ClientID = clientID; // TO-DO: remove trigger in database contact.IsActive = true; try { int userID = SessionHelper.getUserId(); CRM.Data.Entities.SecUser secUser = SecUserManager.GetByUserId(userID); string email = secUser.Email; string password = SecurityManager.Decrypt(secUser.emailPassword); string url = "https://" + secUser.emailHost + "/EWS/Exchange.asmx"; ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1); service.Credentials = new WebCredentials(email, password); service.Url = new Uri(url); Microsoft.Exchange.WebServices.Data.Contact outlookContact = new Microsoft.Exchange.WebServices.Data.Contact(service); outlookContact.GivenName = txtFirstName.Text; outlookContact.Surname = txtLastName.Text; outlookContact.FileAsMapping = FileAsMapping.SurnameCommaGivenName; outlookContact.EmailAddresses[EmailAddressKey.EmailAddress1] = txtEmail.Text; outlookContact.PhoneNumbers[PhoneNumberKey.HomePhone] = txtPhone.Text; outlookContact.Save(); } catch (Exception ex) { } } else { contact = ContactManager.Get(contactID); } if (contact != null) { contact.CompanyName = txtCompanyName.Text; contact.DepartmentName = txtDepartmentName.Text; contact.ContactTitle = txtContactTile.Text; contact.FirstName = txtFirstName.Text; contact.LastName = txtLastName.Text; contact.ContactName = txtFirstName.Text + " " + txtLastName.Text; contact.Address1 = txtAddress1.Text; contact.Address2 = txtAddress2.Text; contact.Mobile = txtMobile.Text; contact.Phone = txtPhone.Text; contact.Email = txtEmail.Text; contact.Fax = txtContactFax.Text; contact.County = txtCounty.Text; //contact.ClaimName = txtClaimName.Text; if (ddlState.SelectedIndex > 0) { contact.StateID = Convert.ToInt32(ddlState.SelectedValue); } if (ddlCity.SelectedIndex > 0) { contact.CityID = Convert.ToInt32(ddlCity.SelectedValue); } if (ddlContactType.SelectedIndex > 0) { contact.CategoryID = Convert.ToInt32(ddlContactType.SelectedValue); } if (ddlLossZip.SelectedIndex > 0) { contact.ZipCodeID = Convert.ToInt32(ddlLossZip.SelectedValue); } decimal.TryParse(txtBalance.Text, out balance); contact.Balance = balance; try { ContactManager.Save(contact); pnlContact.Visible = true; pnlContactDetail.Visible = false; loadData(null); } catch (Exception ex) { EmailHelper.emailError(ex); } } }
public List <string> getEmailData(int claimId, int BusinessRuleID) { List <string> emailData = new List <string>(); string adjusterEmail = ""; int adjusterId = 0; int superVisorId = 0; string adjusterClaimNumber = ""; string dateRecieved = ""; int ruleId = 0; string businessDescription = ""; string redFlagName = ""; string insuredName = ""; string adjusterName = ""; ClaimManager ClaimManagerObj = new ClaimManager(); Claim claimObj = new Claim(); claimObj = ClaimManagerObj.Get(claimId); if (claimObj != null && claimObj.AdjusterID != null) { adjusterId = Convert.ToInt32(claimObj.AdjusterID); } if (claimObj != null && claimObj.InsurerClaimNumber != null) { adjusterClaimNumber = claimObj.InsurerClaimNumber; } if (claimObj != null && claimObj.DateOpenedReported != null) { dateRecieved = Convert.ToString(claimObj.DateOpenedReported); } AdjusterMaster adjusterMasterObj = new AdjusterMaster(); if (claimObj != null) { adjusterMasterObj = claimObj.AdjusterMaster; } if (adjusterMasterObj != null && adjusterMasterObj.email != null) { adjusterEmail = Convert.ToString(adjusterMasterObj.email); } if (adjusterMasterObj != null && adjusterMasterObj.adjusterName != null) { adjusterName = Convert.ToString(adjusterMasterObj.adjusterName); } if (adjusterMasterObj != null && adjusterMasterObj.SupervisorID != null) { superVisorId = Convert.ToInt32(adjusterMasterObj.SupervisorID); } CRM.Data.Entities.SecUser secUserObj = new CRM.Data.Entities.SecUser(); secUserObj = getSecUser(superVisorId); insuredName = claimObj.LeadPolicy.Leads.insuredName; BusinessRuleManager BusinessRuleManagerObj = new BusinessRuleManager(); BusinessRule BusinessRuleObj = new BusinessRule(); BusinessRuleObj = BusinessRuleManagerObj.GetBusinessRule(BusinessRuleID); if (BusinessRuleObj.RuleID != null) { ruleId = Convert.ToInt32(BusinessRuleObj.RuleID); } ; businessDescription = BusinessRuleObj.Description; CRM.Data.Entities.Rule ruleObj = new CRM.Data.Entities.Rule(); ruleObj = BusinessRuleManagerObj.GetRule(ruleId); redFlagName = ruleObj.RuleName; string encryptedClaimNumber = Core.SecurityManager.EncryptQueryString(claimId.ToString()); emailData.Add(adjusterEmail); emailData.Add(adjusterName); emailData.Add(secUserObj.Email); emailData.Add(secUserObj.UserName); emailData.Add(adjusterClaimNumber); emailData.Add(dateRecieved); emailData.Add(businessDescription); emailData.Add(redFlagName); emailData.Add(insuredName); emailData.Add(encryptedClaimNumber); return(emailData); }