Beispiel #1
0
        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 ??
        }
Beispiel #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int userID = 0;

            if (Session["UserId"] != null && int.TryParse(Session["UserId"].ToString(), out userID) && userID > 0)
            {
                CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(userID);

                if (user != null)
                {
                    user.emailHost = txtEmailHost.Text.Trim();

                    user.emailHostPort = txtHostPostNumber.Text.Trim();

                    user.emailSignature = txtEmailSignature.Text.Trim();

                    user.Email = txtEmail.Text.Trim();

                    user.isSSL = cbxSSL.Checked;

                    if (!string.IsNullOrEmpty(txtEmailPassword.Text) && txtEmailPassword.Text != "pass")
                    {
                        user.emailPassword = SecurityManager.Encrypt(txtEmailPassword.Text);
                    }

                    lblMessage.Visible = true;

                    try {
                        SecUserManager.Save(user);

                        lblMessage.Text = "Changes saved successfully.";
                    }
                    catch (Exception ex) {
                        lblMessage.Text = "Error saving changes.";
                    }
                }
            }
        }
        private void bindData()
        {
            Data.Entities.SecUser user = null;
            user = new Data.Entities.SecUser();
            var a = SecUserManager.GetByUserId(userID);

            switch (roleID)
            {
            case (int)UserRole.Administrator:
                break;


            case (int)UserRole.Client:
            case (int)UserRole.SiteAdministrator:
                BindClientPanel();

                claimProgressChart.bindData(clientID);

                ruleExceptionChart.bindData(clientID);
                break;

            default:
                BindUserPanel();
                if (a.isViewAllClaims == true)
                {
                    claimProgressChart.bindData(clientID);
                }
                else
                {
                    claimProgressChart.bindData(clientID, userID);
                }


                ruleExceptionChart.bindData(clientID);
                break;
            }
        }
        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;
            }
        }
Beispiel #5
0
        //protected void lvData_PreRender(object sender, EventArgs e) {

        //	//DoBind();

        //	string sortExpression = ViewState["lastSortExpression"] == null ? "LastName" : ViewState["lastSortExpression"].ToString();
        //	bool descending = ViewState["lastSortDirection"] == null ? false : (bool)ViewState["lastSortDirection"];

        //	Expression<Func<SecUser, bool>> predicate = buildPredicate();

        //	IQueryable<SecUser> secUsers = SecUserManager.GetUsers(predicate);

        //	gvUsers.DataSource = secUsers.orderByExtension(sortExpression, descending);
        //	gvUsers.DataBind();

        //}

        //protected void gvUsers_ItemDataBound(object sender, ListViewItemEventArgs e) {
        //	if (e.Item.ItemType == ListViewItemType.DataItem) {
        //		ImageButton imgDelete = (ImageButton)e.Item.FindControl("imgDelete");
        //		Label lbltotal = (Label)e.Item.FindControl("lbltotal");
        //		if (imgDelete != null) {
        //			if (imgDelete.Enabled == false)
        //				imgDelete.Style.Add(HtmlTextWriterStyle.Cursor, "default");
        //		}

        //		if (SessionHelper.getUserName() == "admin") {
        //			ImageButton btnImpersonate = (ImageButton)e.Item.FindControl("btnImpersonate");
        //			btnImpersonate.Visible = true;
        //		}
        //	}
        //}

        protected void impersonateUser(int userID)
        {
            List <SecRoleModuleManager.secRoleModuleGet> resRolePermission = new List <SecRoleModuleManager.secRoleModuleGet>();
            string userData = null;

            CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(userID);
            if (user != null)
            {
                Session["UserId"]   = user.UserId;
                Session["UserName"] = user.UserName;
                Session["RoleId"]   = user.SecRole.RoleId.ToString();

                // 201307-29
                Session["ClientId"] = user.ClientID;

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

                var url = FormsAuthentication.DefaultUrl;
                Response.Redirect(url);
            }
        }
        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);
                }
            }
        }
Beispiel #7
0
        //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);
        }
Beispiel #8
0
        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();
        }
Beispiel #9
0
        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)
                {
                }
            }
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        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;
            int      clientID    = 0;

            string[]      recipient = null;
            List <string> emails    = null;

            CRM.Data.Entities.SecUser user = null;
            string decryptedPassword       = null;

            string fromEmail = null;
            string subject   = txtEmailSubject.Text.Trim();
            string bodyText  = txtEmailText.Text.Trim();

            user = SecUserManager.GetByUserId(SessionHelper.getUserId());

            if (user == null)
            {
                return;
            }

            int roleID = SessionHelper.getUserRoleId();

            if (roleID == (int)UserRole.Client || roleID == (int)UserRole.SiteAdministrator)
            {
                clientID = SessionHelper.getClientId();

                emails = LeadsManager.GetLeadEmails(clientID);
            }
            else
            {
                emails = LeadsManager.GetLeadEmails();
            }

            fromEmail          = user.Email;
            txtEmailText.Text += "\n\n" + user.emailSignature ?? "";

            decryptedPassword = Core.SecurityManager.Decrypt(user.emailPassword);

            if (fileUpload.HasFile && fileUpload.PostedFile.ContentLength > 0)
            {
                attachments = new string[] { Path.GetFullPath(fileUpload.PostedFile.FileName) };
            }

            if (emails != null && emails.Count > 0)
            {
                try {
                    foreach (string email in emails)
                    {
                        recipient = new string[] { email };

                        Core.EmailHelper.sendEmail(fromEmail, recipient, null, subject, bodyText, attachments, user.Email, decryptedPassword);
                    }
                    lblMessage.Text     = "Email broadcast complete.";
                    lblMessage.CssClass = "ok";
                }
                catch (Exception ex) {
                    lblMessage.Text     = "Email broadcast failed.";
                    lblMessage.CssClass = "error";
                }
            }
        }
Beispiel #13
0
        // bind users to scheduler
        private void bindResources()
        {
            List <UserStaff> staffMembers = null;
            Resource         resource     = null;

            CRM.Data.Entities.SecUser secUser = null;

            WebScheduleInfo1.VisibleResources.Clear();

            switch (roleID)
            {
            case (int)UserRole.Client:
            case (int)UserRole.SiteAdministrator:

                staffMembers = SecUserManager.GetStaff(clientID);

                if (staffMembers != null && staffMembers.Count > 0)
                {
                    ActiveResourceKey = staffMembers[0].UserId.ToString();

                    foreach (UserStaff user in staffMembers)
                    {
                        resource              = new Resource();
                        resource.DataKey      = user.UserId.ToString();
                        resource.Name         = user.StaffName;
                        resource.EmailAddress = user.EmailAddress;
                        WebScheduleInfo1.VisibleResources.Add(resource);
                    }
                }
                break;

            default:
                secUser = SecUserManager.GetByUserId(userID);
                if (secUser != null)
                {
                    resource              = new Resource();
                    resource.DataKey      = secUser.UserId.ToString();
                    resource.Name         = string.Format("{0} {1}", secUser.FirstName, secUser.LastName);
                    resource.EmailAddress = secUser.Email;
                    WebScheduleInfo1.VisibleResources.Add(resource);
                }
                break;
            }

            //WebScheduleInfo1.VisibleResources[0] == unassigned
            if (WebScheduleInfo1 != null && WebScheduleInfo1.VisibleResources != null && WebScheduleInfo1.VisibleResources.Count > 0)
            {
                if (!string.IsNullOrEmpty(ActiveResourceKey))
                {
                    Resource activeResource = WebScheduleInfo1.VisibleResources.GetResourceFromKey(ActiveResourceKey);
                    if (activeResource != null && !string.IsNullOrEmpty(activeResource.Name))
                    {
                        WebScheduleInfo1.ActiveResourceName = activeResource.Name;
                    }
                }
                else
                {
                    WebScheduleInfo1.ActiveResourceName = WebScheduleInfo1.VisibleResources[1].Name;

                    ActiveResourceKey = WebScheduleInfo1.VisibleResources[1].DataKey.ToString();
                }
            }
        }
Beispiel #14
0
        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();
        }
Beispiel #15
0
        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);
                }
            }
        }
Beispiel #16
0
        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;
                }
            }
        }
Beispiel #17
0
        protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            lblError.Text      = string.Empty;
            lblSave.Text       = string.Empty;
            lblMessage.Text    = string.Empty;
            lblMessage.Visible = false;
            lblError.Visible   = false;
            lblSave.Visible    = false;
            if (e.CommandName.Equals("DoEdit"))
            {
                Session["UID"] = e.CommandArgument;
                var url = "~/protected/admin/UserEdit.aspx";
                Response.Redirect(url);
            }
            else if (e.CommandName.Equals("DoDelete"))
            {
                try {
                    var user = SecUserManager.GetByUserId(Convert.ToInt32(e.CommandArgument));
                    user.Status = false;
                    SecUserManager.Save(user);
                    DoBind();
                    lblSave.Text    = "Record Deleted Sucessfully.";
                    lblSave.Visible = true;
                }
                catch (Exception ex) {
                    lblError.Text    = "Record Not Deleted.";
                    lblError.Visible = true;
                }
            }
            else if (e.CommandName.Equals("DoView"))
            {
                Session["UIDV"] = e.CommandArgument;
                var url = "~/protected/admin/UserDetail.aspx";
                Response.Redirect(url);

                Response.Redirect(url);
            }
            else if (e.CommandName.Equals("DoUnlock"))
            {
                try {
                    var user = SecUserManager.GetByUserId(Convert.ToInt32(e.CommandArgument));
                    user.Blocked = false;
                    SecUserManager.Save(user);
                    DoBind();
                    lblSave.Text    = "User Unlock Successfully.";
                    lblSave.Visible = true;
                }
                catch (Exception ex) {
                    lblError.Text    = "User Not Unlocked.";
                    lblError.Visible = true;
                }
            }
            else if (e.CommandName.Equals("Dolock"))
            {
                try {
                    var user = SecUserManager.GetByUserId(Convert.ToInt32(e.CommandArgument));
                    user.Blocked = true;
                    SecUserManager.Save(user);
                    DoBind();
                    lblSave.Text    = "User lock Successfully.";
                    lblSave.Visible = true;
                }
                catch (Exception ex) {
                    lblError.Text    = "User Not locked.";
                    lblError.Visible = true;
                }
            }
            else if (e.CommandName.Equals("DoImpersonate"))
            {
                impersonateUser(Convert.ToInt32(e.CommandArgument));
            }
        }
        protected void emailDocumentLink(string finalReportPath, string emailTo, int claimID)
        {
            int    userID   = Core.SessionHelper.getUserId();
            Claim  claim    = null;
            string password = null;
            int    port     = 0;

            string[] recipients = null;
            string   subject    = null;

            Leads         lead           = null;
            string        encryptedQuery = null;
            StringBuilder emailBody      = 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();

            CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(userID);

            if (user != null && !string.IsNullOrEmpty(user.Email) && !string.IsNullOrEmpty(user.emailHost) && !string.IsNullOrEmpty(user.emailHostPort))
            {
                claim = ClaimsManager.Get(claimID);

                if (claim != null)
                {
                    lead = claim.LeadPolicy.Leads;

                    if (string.IsNullOrEmpty(emailTo))
                    {
                        recipients = new string[] { user.Email }
                    }
                    ;
                    else
                    {
                        recipients = emailTo.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
                    }

                    encryptedQuery = Core.SecurityManager.EncryptQueryString(claimID.ToString());

                    emailBody = new StringBuilder();

                    // .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 image
                    emailBody.Append("<div style=\"padding:1px;\"><img src=\"http://app.claimruler.com/images/email_header_small.jpg\"></image></div>");

                    // .paneContentInner
                    emailBody.Append("<div style=\"margin: 20px;\">");

                    subject = string.Format("{0} {1} wants to share {2} Adjuster Claim File with you", user.FirstName, user.LastName, lead.insuredName);

                    emailBody.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\">");
                    emailBody.Append("<tbody><tr><td colspan=\"3\" height=\"36\"></td></tr>");
                    emailBody.Append("<tr><td width=\"36\"></td>");
                    emailBody.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\">");


                    emailBody.Append(string.Format("{0} {1} invited you to a Claim Ruler Software shared file called \"{2}\"", user.FirstName, user.LastName, lead.insuredName));

                    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";

                    // user app siteURL for report.pdf
                    emailBody.Append(string.Format("<br/><br/><center><a style=\"{0}\" href=\"{1}/Temp/{2}\">View Report</a></center>",
                                                   css, ConfigurationManager.AppSettings["siteURL"], Path.GetFileName(finalReportPath)));

                    emailBody.Append(string.Format("<br/><br/><center><a style=\"{0}\" href=\"{1}/Content/Public.aspx?q={2}\">View Files</a></center></td>",
                                                   css, ConfigurationManager.AppSettings["siteURL"], encryptedQuery));

                    emailBody.Append("<td width='36'></td></tr><tr><td colspan='3' height='36'></td></tr></tbody></table>");

                    emailBody.Append("</div>");                         // paneContentInner
                    emailBody.Append("</div>");                         // containerBox

                    //int.TryParse(user.emailHostPort, out port);
                    int.TryParse(itsgHostPort, out port);

                    password = SecurityManager.Decrypt(user.emailPassword);

                    Core.EmailHelper.sendEmail(user.Email, recipients, null, subject, emailBody.ToString(), null, itsgHost, port, itsgEmail, itsgEmailPassword);
                }
            }
            else
            {
                throw new Exception("Unable to export claim. Please verify user email settings.");
            }
        }
Beispiel #19
0
        private void bindTasks(DateTime fromDate, DateTime toDate)
        {
            List <LeadTask> tasks = null;

            Expression <Func <CRM.Data.Entities.Task, bool> > predicate = PredicateBuilder.True <CRM.Data.Entities.Task>();

            if (roleID == (int)UserRole.Administrator)
            {
            }
            else if ((roleID == (int)UserRole.Client || roleID == (int)UserRole.SiteAdministrator) && clientID > 0)
            {
                // load all tasks for client (sort of admin)

                predicate = predicate.And(LeadTask => LeadTask.creator_id == clientID);

                predicate = predicate.And(LeadTask => LeadTask.start_date >= fromDate && LeadTask.end_date <= toDate);

                // get overdue task for client
                predicate = predicate.Or(LeadTask => LeadTask.status_id == 1 && LeadTask.end_date <= toDate && LeadTask.creator_id == clientID);
            }
            else
            {
                // regular users

                predicate = predicate.And(LeadTask => LeadTask.start_date >= fromDate && LeadTask.end_date <= toDate);

                predicate = predicate.And(LeadTask => LeadTask.owner_id == userID);
            }

            tasks = TasksManager.GetLeadTask(predicate, fromDate, toDate);

            if (rbOn.Checked)
            {
                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);

                try
                {
                    TasksFolder tasksfolder = TasksFolder.Bind(service, WellKnownFolderName.Tasks);

                    ItemView view = new ItemView(int.MaxValue);
                    FindItemsResults <Item> OutlookTasks = tasksfolder.FindItems(view);

                    CalendarView calView = new CalendarView(fromDate, toDate);

                    FindItemsResults <Item> instanceResults = service.FindItems(WellKnownFolderName.Calendar, calView);

                    foreach (var item in instanceResults)
                    {
                        LeadTask newTask = new LeadTask();
                        Microsoft.Exchange.WebServices.Data.Appointment appointment = item as Microsoft.Exchange.WebServices.Data.Appointment;

                        newTask.creator_id = userID;
                        newTask.details    = appointment.Subject;
                        newTask.end_date   = appointment.End;
                        newTask.isAllDay   = appointment.IsRecurring;
                        newTask.text       = appointment.Subject;

                        newTask.priorityName = appointment.Importance.ToString();
                        newTask.owner_name   = appointment.Organizer.Name;
                        newTask.start_date   = appointment.Start;

                        tasks.Add(newTask);
                    }

                    foreach (var task in OutlookTasks)
                    {
                        task.Load();
                        Microsoft.Exchange.WebServices.Data.Task myTask = task as Microsoft.Exchange.WebServices.Data.Task;

                        LeadTask newTask = new LeadTask();
                        newTask.creator_id   = userID;
                        newTask.details      = ExtractHtmlInnerText(myTask.Body.Text);
                        newTask.end_date     = myTask.DueDate;
                        newTask.isAllDay     = myTask.IsRecurring;
                        newTask.text         = myTask.Subject;
                        newTask.statusName   = myTask.Status.ToString();
                        newTask.priorityName = myTask.Importance.ToString();
                        newTask.owner_name   = myTask.Owner;
                        if (myTask.StartDate == null)
                        {
                            newTask.start_date = myTask.DueDate;
                        }
                        else
                        {
                            newTask.start_date = myTask.StartDate;
                        }

                        tasks.Add(newTask);
                    }
                }
                catch (Exception ex)
                {
                }
            }
            // show tasks
            gvTasks.DataSource = tasks;
            gvTasks.DataBind();
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text    = string.Empty;
            lblSave.Text     = string.Empty;
            lblSave.Visible  = false;
            lblError.Visible = false;
            try {
                using (TransactionScope scope = new TransactionScope()) {
                    SecRoleModuleManager.UpdateSecRoleModuleStatus(Convert.ToInt32(ddlRole.SelectedValue));

                    foreach (GridViewRow row in grdModule.Rows)
                    {
                        int         check          = 0;
                        int         checkParent    = 0;
                        GridView    gv             = (GridView)row.FindControl("gvSubModule");
                        HiddenField hfRoleModuleId = (HiddenField)row.FindControl("hfRoleModuleId");
                        HiddenField hfModuleId     = (HiddenField)row.FindControl("hfModuleId");

                        if (hfRoleModuleId.Value == string.Empty)
                        {
                            hfRoleModuleId.Value = "0";
                        }

                        CheckBox chkAllAdd  = (CheckBox)row.FindControl("chkAllAdd");
                        CheckBox chkAllEdit = (CheckBox)row.FindControl("chkAllEdit");
                        CheckBox chkAllDel  = (CheckBox)row.FindControl("chkAllDel");
                        CheckBox chkAllView = (CheckBox)row.FindControl("chkAllView");

                        SecRoleModule roleModuleMainGrid = SecRoleModuleManager.GetByRoleModuleId(Convert.ToInt32(hfRoleModuleId.Value));
                        if (chkAllView.Checked || chkAllAdd.Checked || chkAllEdit.Checked || chkAllEdit.Checked)
                        {
                            var secRoleModule = new CRM.Data.Entities.SecRoleModule {
                                ModuleID         = Convert.ToInt32(hfModuleId.Value),
                                RoleID           = Convert.ToInt32(ddlRole.SelectedValue),
                                AddPermssion     = chkAllAdd.Checked == true ? true : false,
                                EditPermission   = chkAllEdit.Checked == true ? true : false,
                                DeletePermission = chkAllDel.Checked == true ? true : false,
                                ViewPermission   = chkAllView.Checked == true ? true : false,
                                Status           = 1,
                                CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                CreatedOn        = DateTime.Now,
                                UpdatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                UpdatedOn        = DateTime.Now,
                                CreatedMachineIP = Request.ServerVariables["remote_addr"].ToString(),
                            };
                            SecRoleModuleManager.SaveRoleModule(secRoleModule);
                            checkParent = 1;
                        }


                        foreach (GridViewRow subGridRow in gv.Rows)
                        {
                            CheckBox      chkAdd          = (CheckBox)subGridRow.FindControl("chkAdd");
                            CheckBox      chkEdit         = (CheckBox)subGridRow.FindControl("chkEdit");
                            CheckBox      chkDelete       = (CheckBox)subGridRow.FindControl("chkDel");
                            CheckBox      chkView         = (CheckBox)subGridRow.FindControl("chkView");
                            HiddenField   hfModuleIdChild = (HiddenField)subGridRow.FindControl("hfModuleIdChild");
                            SecRoleModule roleModule      = SecRoleModuleManager.GetByRoleModuleId(Convert.ToInt32(hfRoleModuleId.Value));
                            if (chkAdd.Checked || chkEdit.Checked || chkDelete.Checked || chkView.Checked)
                            {
                                var secRoleModuleChild = new CRM.Data.Entities.SecRoleModule {
                                    ModuleID         = Convert.ToInt32(hfModuleIdChild.Value),
                                    RoleID           = Convert.ToInt32(ddlRole.SelectedValue),
                                    AddPermssion     = chkAdd.Checked == true ? true : false,
                                    EditPermission   = chkEdit.Checked == true ? true : false,
                                    DeletePermission = chkDelete.Checked == true ? true : false,
                                    ViewPermission   = chkView.Checked == true ? true : false,
                                    Status           = 1,
                                    CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                    CreatedOn        = DateTime.Now,
                                    UpdatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                    UpdatedOn        = DateTime.Now,
                                    CreatedMachineIP = Request.ServerVariables["remote_addr"].ToString(),
                                };
                                SecRoleModuleManager.SaveRoleModule(secRoleModuleChild);
                                check       = 1;
                                checkParent = 0;
                            }

                            GridView gvchild = (GridView)subGridRow.FindControl("gvSubModule1");
                            if (gvchild.Rows.Count > 0)
                            {
                                foreach (GridViewRow child in gvchild.Rows)
                                {
                                    CheckBox      chkAdd1          = (CheckBox)child.FindControl("chkAdd");
                                    CheckBox      chkEdit1         = (CheckBox)child.FindControl("chkEdit");
                                    CheckBox      chkDelete1       = (CheckBox)child.FindControl("chkDel");
                                    CheckBox      chkView1         = (CheckBox)child.FindControl("chkView");
                                    HiddenField   hfModuleIdChild1 = (HiddenField)child.FindControl("hfModuleIdChild1");
                                    SecRoleModule roleModule1      = SecRoleModuleManager.GetByRoleModuleId(Convert.ToInt32(hfRoleModuleId.Value));
                                    if (chkAdd1.Checked || chkEdit1.Checked || chkDelete1.Checked || chkView1.Checked)
                                    {
                                        var secRoleModuleChild = new CRM.Data.Entities.SecRoleModule {
                                            ModuleID         = Convert.ToInt32(hfModuleIdChild1.Value),
                                            RoleID           = Convert.ToInt32(ddlRole.SelectedValue),
                                            AddPermssion     = chkAdd.Checked == true ? true : false,
                                            EditPermission   = chkEdit.Checked == true ? true : false,
                                            DeletePermission = chkDelete.Checked == true ? true : false,
                                            ViewPermission   = chkView.Checked == true ? true : false,
                                            Status           = 1,
                                            CreatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                            CreatedOn        = DateTime.Now,
                                            UpdatedBy        = Convert.ToInt32(HttpContext.Current.User.Identity.Name),
                                            UpdatedOn        = DateTime.Now,
                                            CreatedMachineIP = Request.ServerVariables["remote_addr"].ToString(),
                                        };
                                        SecRoleModuleManager.SaveRoleModule(secRoleModuleChild);
                                        check       = 1;
                                        checkParent = 0;
                                    }
                                }
                            }
                        }
                    }

                    CRM.Data.Entities.SecUser user = SecUserManager.GetByUserId(Convert.ToInt32(HttpContext.Current.User.Identity.Name));
                    if (user.SecRole.RoleId == Convert.ToInt32(ddlRole.SelectedValue))
                    {
                        Session["rolePermission"] = refreshRolePermission = SecRoleModuleManager.getRolePermission(user.SecRole.RoleId).ToList();
                    }
                    bindGrid(Convert.ToInt32(ddlRole.SelectedValue));
                    lblSave.Text    = "Record Saved Sucessfully.";
                    lblSave.Visible = true;
                    scope.Complete();
                }
            }
            catch (Exception ex) {
                lblError.Text    = "Record Not Saved Sucessfully.";
                lblError.Visible = true;
            }
        }
Beispiel #21
0
        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);
            }
        }
        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;
                }
            }
        }
Beispiel #23
0
        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);
                }
            }
        }
Beispiel #24
0
        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");
        }