protected void gvComments_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int          commentID = Convert.ToInt32(e.CommandArgument);
            ClaimComment comment   = null;

            if (e.CommandName == "DoEdit")
            {
                comment = ClaimCommentManager.Get(commentID);
                if (comment != null)
                {
                    showCommentEditPanel();

                    ViewState["CommentID"]        = commentID.ToString();
                    ddlActivity.SelectedItem.Text = comment.ActivityType;
                    if (comment.StartDate != null)
                    {
                        txtStartDate.Text = comment.StartDate.ToString();
                    }
                    if (comment.EndDate != null)
                    {
                        txtEndDate.Text = comment.EndDate.ToString();
                    }

                    txtComment.Text = comment.CommentText;
                }
            }
            else if (e.CommandName == "DoDelete")
            {
                ClaimCommentManager.Delete(commentID);
                dataBind(this.claimID);
            }
        }
示例#2
0
        protected void addInvoiceToClaimDiary(Invoice invoice, InvoiceDetail invoiceDetail)
        {
            ClaimComment comment = null;

            // retrieve comment by reference
            //comment = ClaimCommentManager.GetLeadCommentByReferenceId(invoiceDetail.InvoiceLineID);

            if (comment == null)
            {
                comment = new ClaimComment();
            }

            comment.UserId      = Core.SessionHelper.getUserId();
            comment.CommentDate = DateTime.Now;
            comment.ClaimID     = invoice.ClaimID;
            //comment.ReferenceID = invoiceDetail.InvoiceLineID;
            comment.IsActive    = true;                 // active
            comment.CommentText = string.Format("<div>Invoice # {0} - {1:MM-dd-yyyy} for {2} Qty:{3:N2} Rate:{4:N2} Item Total:{5:N2}</div><div>{6}</div>",
                                                invoice.InvoiceNumber,
                                                invoiceDetail.LineDate,
                                                invoiceDetail.LineDescription ?? "",
                                                invoiceDetail.Qty ?? 0,
                                                invoiceDetail.Rate ?? 0,
                                                invoiceDetail.LineAmount ?? 0,
                                                invoiceDetail.Comments ?? ""
                                                );

            ClaimCommentManager.Save(comment);
        }
示例#3
0
        protected void btnDocumentsSave_Click(object sender, EventArgs e)
        {
            for (int rowCount = 0; rowCount < gvSearchResult.Rows.Count; rowCount++)
            {
                CheckBox box = (CheckBox)gvSearchResult.Rows[rowCount].Cells[0].Controls[1];
                if (box.Checked)
                {
                    int          commentID = 0;
                    ClaimComment comment   = null;

                    comment             = new ClaimComment();
                    comment.ClaimID     = this.claimID;
                    comment.IsActive    = true;
                    comment.UserId      = Core.SessionHelper.getUserId();
                    comment.CommentDate = DateTime.Now;

                    string serviceUrl = ConfigurationManager.AppSettings["importServiceUrl"];
                    serviceUrl = serviceUrl + "/" + "ExportNotes?commentId=" + commentID;
                    Common.SendRequest(serviceUrl);
                    if (comment != null && comment.ClaimID > 0)
                    {
                        comment.CommentText = gvSearchResult.Rows[rowCount].Cells[2].Text;

                        try
                        {
                            ClaimCommentManager.Save(comment);
                            EmailMessage msg = instanceResults.Items[rowCount] as EmailMessage;
                            if (msg.HasAttachments)
                            {
                                foreach (Attachment attachment in msg.Attachments)
                                {
                                    if (attachment is FileAttachment)
                                    {
                                        FileAttachment fileAttachment = attachment as FileAttachment;

                                        // Load the attachment into a file.
                                        // This call results in a GetAttachment call to EWS.
                                        string tempName = HttpContext.Current.Server.MapPath(String.Format("~\\Temp\\{0}", fileAttachment.Name));
                                        fileAttachment.Load(tempName);
                                        ClaimEdit.saveFile(claimID, fileAttachment.Name, "Attachment from email " + msg.Subject, 6);
                                        File.Delete(tempName);
                                    }
                                }
                            }
                            lblErrorMSg.Text    = "Email(s) Saved successfully";
                            lblErrorMSg.Visible = true;
                        }
                        catch (Exception ex)
                        {
                            lblErrorMSg.Text     = "Mail not saved!";
                            lblErrorMSg.CssClass = "error";
                            Core.EmailHelper.emailError(ex);
                        }
                    }
                }
            }
        }
示例#4
0
        public static ClaimComment Get(int id)
        {
            ClaimComment comment = null;

            comment = (from x in DbContextHelper.DbContext.ClaimComment
                       where x.CommentID == id
                       select x
                       ).FirstOrDefault <ClaimComment>();

            return(comment);
        }
示例#5
0
        public static ClaimComment Save(ClaimComment comment)
        {
            if (comment.CommentID == 0)
            {
                DbContextHelper.DbContext.Add(comment);
            }

            DbContextHelper.DbContext.SaveChanges();

            return(comment);
        }
        protected void btnCommentSave_Click(object sender, EventArgs e)
        {
            int commentID = Convert.ToInt32(ViewState["CommentID"]);

            ClaimComment comment = null;

            lblMessage.Text = string.Empty;

            if (commentID == 0)
            {
                comment             = new ClaimComment();
                comment.ClaimID     = this.claimID;
                comment.IsActive    = true;
                comment.UserId      = Core.SessionHelper.getUserId();
                comment.CommentDate = DateTime.Now;
            }
            else
            {
                comment = ClaimCommentManager.Get(commentID);
            }
            string serviceUrl = ConfigurationManager.AppSettings["importServiceUrl"];

            serviceUrl = serviceUrl + "/" + "ExportNotes?commentId=" + commentID;
            Common.SendRequest(serviceUrl);
            if (comment != null && comment.ClaimID > 0)
            {
                comment.CommentText  = txtComment.Text.Trim();
                comment.ActivityType = ddlActivity.SelectedItem.Text;
                if (!string.IsNullOrEmpty(txtStartDate.Text))
                {
                    comment.StartDate = Convert.ToDateTime(txtStartDate.Text);
                }
                if (!string.IsNullOrEmpty(txtEndDate.Text))
                {
                    comment.EndDate = Convert.ToDateTime(txtEndDate.Text);
                }

                try {
                    ClaimCommentManager.Save(comment);

                    showCommentGridPanel();

                    dataBind(this.claimID);
                }
                catch (Exception ex) {
                    lblMessage.Text     = "Comment not saved!";
                    lblMessage.CssClass = "error";
                    Core.EmailHelper.emailError(ex);
                }
            }
        }
示例#7
0
        protected void btnImportEmail_Click(object sender, EventArgs e)
        {
            ClaimComment comment = null;
            DateTime     date    = DateTime.MinValue;

            try {
                foreach (GridViewRow row in gvMails.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        CheckBox cbxImport = row.FindControl("cbxImport") as CheckBox;

                        if (cbxImport != null && cbxImport.Checked)
                        {
                            Label receivedDate = row.FindControl("ReceivedDate") as Label;

                            comment = new ClaimComment();

                            comment.ClaimID  = this.claimID;
                            comment.IsActive = true;

                            if (receivedDate != null && !string.IsNullOrEmpty(receivedDate.Text))
                            {
                                DateTime.TryParse(receivedDate.Text, out date);
                                comment.CommentDate = date;
                            }

                            comment.UserId = this.userID;

                            WebHtmlEditor txtContents = row.FindControl("txtContents") as WebHtmlEditor;
                            if (txtContents != null && !string.IsNullOrEmpty(txtContents.Text))
                            {
                                comment.CommentText = txtContents.Text.Trim();
                            }

                            ClaimCommentManager.Save(comment);
                        }
                    }
                }
                lblMessage.Text     = "Selected emails have been imported successfully.";
                lblMessage.CssClass = "ok";
            }
            catch (Exception ex) {
                lblMessage.Text     = "Email import failure.";
                lblMessage.CssClass = "error";

                Core.EmailHelper.emailError(ex);
            }
        }
示例#8
0
        public static void Delete(int id)
        {
            // Create an entity to represent the Entity you wish to delete
            // Notice you don't need to know all the properties, in this
            // case just the ID will do.
            ClaimComment comment = Get(id);

            if (comment != null)
            {
                // Do the delete the category
                DbContextHelper.DbContext.DeleteObject(comment);

                // Apply the delete to the database
                DbContextHelper.DbContext.SaveChanges();
            }
        }
示例#9
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);
            }
        }
        public static string SaveNotes(int claimID, string serviceQty, string serviceDate, string descp, string invoiceServiceType, int invoiceServiceTypeId, string serviceAdjuster, string serviceAdjustId, int leadID, string emailTo)
        {
            string json = "";
            ClaimService claimService = null;
            ClaimComment diary = null;
            Leads objLeads = null;
            Claim objClaim = null;
            int userID = SessionHelper.getUserId();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimServiceManager repository = new ClaimServiceManager())
                    {
                        claimService = new ClaimService();
                        claimService.ClaimID = claimID;

                        claimService.ServiceQty = serviceQty == null ? 0 : Convert.ToDecimal(serviceQty);
                        claimService.ServiceDate = Convert.ToDateTime(serviceDate);
                        claimService.ServiceDescription = descp.Trim();
                        claimService.ServiceTypeID = Convert.ToInt32(invoiceServiceTypeId);
                        claimService.UserID = userID;
                        claimService.AdjusterID = Convert.ToInt32(serviceAdjustId);

                        claimService = repository.Save(claimService);
                    }

                    // diary
                    diary = new ClaimComment();
                    diary.ClaimID = claimID;
                    diary.CommentDate = DateTime.Now;
                    diary.UserId = userID;
                    diary.ActivityType = "Service: " + invoiceServiceType;
                    diary.CommentText = string.Format("Description: {0}, Date {1:MM/dd/yyyy h:mm}, Qty: {2:N2}, Adjuster: {3}",
                                                claimService.ServiceDescription,
                                                claimService.ServiceDate,
                                                claimService.ServiceQty,
                                                serviceAdjuster
                                                );
                    ClaimCommentManager.Save(diary);

                    scope.Complete();
                    //  SendNoteEmail();
                }
                objLeads = LeadsManager.GetByLeadId(leadID);
                ClaimManager objClaimManager = new ClaimManager();
                objClaim = objClaimManager.Get(claimID);
                string insuerFileId = objClaim.InsurerClaimNumber;
                string insurerName = objLeads.InsuredName;
                string claimNumber = objClaim.AdjusterClaimNumber;
                string userName = SessionHelper.getUserName();
                SendNoteEmail(insuerFileId, insurerName, claimNumber, serviceAdjuster, descp.Trim(), userName, emailTo, serviceDate, serviceQty);

                json = "Service save successfully";

            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);
            }

            return json;
        }
        protected void btnSaveExpense_Click(object sender, EventArgs e)
        {
            Claim                 claim          = null;
            Claim                 myClaim        = null;
            ClaimExpense          claimExpense   = null;
            AdjusterMaster        adjuster       = null;
            CarrierInvoiceProfile CarrierInvoice = null;

            int clientID      = SessionHelper.getClientId();
            int userID        = SessionHelper.getUserId();
            int claimID       = SessionHelper.getClaimID();
            int myAdjusterID  = 0;
            int profileID     = 0;
            int expenseTypeID = 0;
            int id            = 0;


            Page.Validate("expense");
            if (!Page.IsValid)
            {
                return;
            }

            id = Convert.ToInt32(ViewState["ClaimExpenseID"]);

            ClaimManager cm = new ClaimManager();

            myClaim = cm.Get(claimID);

            try
            {
                expenseTypeID = Convert.ToInt32(ddlExpenseType.SelectedValue);

                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimExpenseManager repository = new ClaimExpenseManager())
                    {
                        if (id == 0)
                        {
                            claimExpense         = new ClaimExpense();
                            claimExpense.ClaimID = claimID;
                        }
                        else
                        {
                            claimExpense = repository.Get(id);
                        }

                        // populate fields
                        if (txtExpenseAmount.Visible == false)
                        {
                            var x = Session["multiplier"].ToString();

                            double expenseAmount = Convert.ToDouble(x) * Convert.ToDouble(txtExpenseQty.ValueDecimal); //newOC 10/7/14
                            claimExpense.ExpenseAmount = Convert.ToDecimal(expenseAmount);

                            decimal d = Convert.ToDecimal(expenseAmount);
                            //Session["EmailAmount"] = "$" + Math.Round(d, 2);
                            Session["EmailAmount"] = String.Format("{0:0.00}", expenseAmount);
                            // Session["EmailAmount"] = expenseAmount;
                        }
                        else
                        {
                            claimExpense.ExpenseAmount = txtExpenseAmount.ValueDecimal;
                        }
                        claimExpense.ExpenseDate        = txtExpenseDate.Date;
                        claimExpense.ExpenseDescription = txtExpenseDescription.Text.Trim();
                        claimExpense.ExpenseTypeID      = expenseTypeID;
                        claimExpense.IsReimbursable     = cbxExpenseReimburse.Checked;
                        claimExpense.UserID             = userID;
                        claimExpense.AdjusterID         = Convert.ToInt32(hf_expenseAdjusterID.Value);
                        claimExpense.ExpenseQty         = txtExpenseQty.ValueDecimal;
                        claimExpense.InternalComments   = txtMyComments.Text.Trim();
                        claimExpense.Billed             = false;
                        // claimExpense.IsBillable = cbIsBillable.Checked;
                        // save expense
                        claimExpense = repository.Save(claimExpense);
                    }

                    // update diary entry
                    ClaimComment diary = new ClaimComment();
                    diary.ClaimID     = claimID;
                    diary.CommentDate = DateTime.Now;
                    diary.UserId      = userID;
                    diary.CommentText = string.Format("Expense: {0}, Description: {1}, Date: {2:MM/dd/yyyy}, Amount: {3:N2}, Adjuster: {4} Qty: {5:N2}",
                                                      ddlExpenseType.SelectedItem.Text,
                                                      claimExpense.ExpenseDescription,
                                                      claimExpense.ExpenseDate,
                                                      claimExpense.ExpenseAmount,
                                                      txtExpenseAdjuster.Text,
                                                      claimExpense.ExpenseQty
                                                      );
                    ClaimCommentManager.Save(diary);

                    // 2014-05-02 apply rule
                    using (SpecificExpenseTypePerCarrier ruleEngine = new SpecificExpenseTypePerCarrier())
                    {
                        claim         = new Claim();
                        claim.ClaimID = claimID;
                        RuleException ruleException = ruleEngine.TestRule(clientID, claim, expenseTypeID);

                        if (ruleException != null)
                        {
                            ruleException.UserID = Core.SessionHelper.getUserId();
                            ruleEngine.AddException(ruleException);
                            CheckSendMail(ruleException);
                        }
                    }
                    myAdjusterID = Convert.ToInt32(claimExpense.AdjusterID); //Convert.ToInt32(myClaim.AdjusterID);
                    //EMAIL ADJUSTER OC 10/22/2014
                    if (myAdjusterID != 0 || myAdjusterID != null)
                    {
                        adjuster = AdjusterManager.GetAdjusterId(myAdjusterID);
                    }
                    if (cbEmailAdjuster.Checked == true)
                    {
                        try
                        {
                            notifyAdjuster(adjuster, claimExpense, myClaim);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text     = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }
                    //EMAIL CLIENT CONTACT OC 10/22/2014
                    if (cbEmailClient.Checked == true)              //Dont need to check if invoice Pro ID is empty becuase to get to this point, one has to exist already
                    {
                        if (Session["ComingFromAllClaims"] != null) //if the user got here straight from the all claims screen
                        {
                            profileID = Convert.ToInt32(Session["CarrierInvoiceID"]);
                        }
                        else//coming from claim detail page
                        {
                            profileID = Convert.ToInt32(Session["InvoiceProfileID"]);
                        }
                        CarrierInvoice = CarrierInvoiceProfileManager.Get(profileID);
                        try
                        {
                            notifyClientContact(CarrierInvoice, claimExpense, myClaim, adjuster);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text     = "Unable to send email to client contact";
                            lblMessage.CssClass = "error";
                        }
                    }
                    //EMAIL TO WHOMEVER OC 10/22/2014
                    if (txtEmailTo.Text != "")
                    {
                        try
                        {
                            notifySpecifiedUser(adjuster, claimExpense, myClaim);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text     = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }

                    // complete transaction
                    scope.Complete();
                }

                lblMessage.Text     = "Expense saved successfully.";
                lblMessage.CssClass = "ok";

                // refresh grid
                gvExpense.DataSource = loadExpenses(claimID);
                gvExpense.DataBind();

                // keep edit form active
                lbtnNewExpense_Click(null, null);
                lblAmount.Text           = "";
                lblAmount.Visible        = false;
                txtExpenseAmount.Visible = true;
            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);

                lblMessage.Text     = "Unable to save claim expense.";
                lblMessage.CssClass = "error";
            }
        }
        protected void btnSaveClaimService_Click(object sender, EventArgs e)
        {
            ClaimService claimService = null;
            ClaimComment diary = null;
            AdjusterMaster adjuster = null;
            Claim myClaim = null;
            CarrierInvoiceProfile CarrierInvoice = null;

            int userID = SessionHelper.getUserId();
            int claimID = SessionHelper.getClaimID();
            int id = 0;
            int myAdjusterID = 0;
            int profileID = 0;

            Page.Validate("service");
            if (!Page.IsValid)
                return;

            id = Convert.ToInt32(ViewState["ClaimServiceID"]);

            //Get current claim info to pass through to emails
            ClaimManager cm = new ClaimManager();
            myClaim =  cm.Get(claimID);

            //AdjusterManager

            try {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimServiceManager repository = new ClaimServiceManager())
                    {
                        if (id == 0)
                        {
                            claimService = new ClaimService();
                            claimService.ClaimID = claimID;
                        }
                        else
                        {
                            claimService = repository.Get(id);
                        }

                        claimService.ServiceQty = this.txtServiceQty.Value == null ? 0 : Convert.ToDecimal(txtServiceQty.Value);
                        claimService.ServiceDate = txtServiceDate.Date;
                        claimService.ServiceDescription = txtServiceDescription.Text.Trim();
                        claimService.ServiceTypeID = Convert.ToInt32(this.ddlInvoiceServiceType.SelectedValue);
                        claimService.UserID = userID;
                        claimService.AdjusterID = Convert.ToInt32(hf_serviceAdjusterID.Value);
                        claimService.Activity = ddlActivity.SelectedItem.Text;
                        claimService.InternalComments = txtMyComments.Text.Trim();
                        claimService.IsBillable = cbIsBillable.Checked;
                        claimService.Billed = false;
                        //save to db
                        claimService = repository.Save(claimService);

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

                    }

                    // diary
                    diary = new ClaimComment();
                    diary.ClaimID = claimID;
                    diary.CommentDate = DateTime.Now;
                    diary.UserId = userID;
                    diary.ActivityType = ddlActivity.SelectedItem.Text;
                    diary.InternalComments = txtMyComments.Text.Trim();
                    diary.CommentText = string.Format("Service: {0}, Description: {1}, Date {2:MM/dd/yyyy}, Qty: {3:N2}, Adjuster: {4}",
                                                ddlInvoiceServiceType.SelectedItem.Text,
                                                claimService.ServiceDescription,
                                                claimService.ServiceDate,
                                                claimService.ServiceQty,
                                                txtServiceAdjuster.Text
                                                );
                    ClaimCommentManager.Save(diary);

                    myAdjusterID = Convert.ToInt32(claimService.AdjusterID); //Convert.ToInt32(myClaim.AdjusterID);

                    //EMAIL ADJUSTER OC 10/21/2014
                    if (myAdjusterID != 0 || myAdjusterID != null)
                    {
                        adjuster = AdjusterManager.GetAdjusterId(myAdjusterID);
                    }
                    if (cbEmailAdjuster.Checked == true)
                    {
                        try
                        {
                            notifyAdjuster(adjuster, claimService, myClaim);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }
                    //EMAIL CLIENT CONTACT OC 10/22/2014
                    if (cbEmailClient.Checked == true) //Dont need to check if invoice Pro ID is empty becuase to get to this point, one has to exist already
                    {
                        if (Session["ComingFromAllClaims"] != null) //if the user got here straight from the all claims screen
                        {
                            profileID = Convert.ToInt32(Session["CarrierInvoiceID"]);
                        }
                        else//coming from claim detail page
                        {
                            profileID = Convert.ToInt32(Session["InvoiceProfileID"]);
                        }
                        CarrierInvoice = CarrierInvoiceProfileManager.Get(profileID);
                        try
                        {
                            notifyClientContact(CarrierInvoice, claimService, myClaim, adjuster);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "Unable to send email to client contact";
                            lblMessage.CssClass = "error";
                        }

                    }
                    //EMAIL TO WHOMEVER
                    if(txtEmailTo.Text != "")
                    {

                        try
                        {
                            notifySpecifiedUser(adjuster, claimService, myClaim);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }

                    scope.Complete();

                }

                lblMessage.Text = "Service was saved successfully.";
                lblMessage.CssClass = "ok";

                // keep edit form active
                lbtnNewClaimService_Click(null, null);

                // refresh grid
                gvClaimService.DataSource = loadClaimServices(claimID);
                gvClaimService.DataBind();

            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);

                lblMessage.Text = "Unable to save claim service.";
                lblMessage.CssClass = "error";
            }
            //send email to adjuster
        }
示例#13
0
        protected void btnSaveClaimService_Click(object sender, EventArgs e)
        {
            ClaimService          claimService   = null;
            ClaimComment          diary          = null;
            AdjusterMaster        adjuster       = null;
            Claim                 myClaim        = null;
            CarrierInvoiceProfile CarrierInvoice = null;

            int userID       = SessionHelper.getUserId();
            int claimID      = SessionHelper.getClaimID();
            int id           = 0;
            int myAdjusterID = 0;
            int profileID    = 0;

            Page.Validate("service");
            if (!Page.IsValid)
            {
                return;
            }

            id = Convert.ToInt32(ViewState["ClaimServiceID"]);

            //Get current claim info to pass through to emails
            ClaimManager cm = new ClaimManager();

            myClaim = cm.Get(claimID);


            //AdjusterManager

            try {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimServiceManager repository = new ClaimServiceManager())
                    {
                        if (id == 0)
                        {
                            claimService         = new ClaimService();
                            claimService.ClaimID = claimID;
                        }
                        else
                        {
                            claimService = repository.Get(id);
                        }

                        claimService.ServiceQty         = this.txtServiceQty.Value == null ? 0 : Convert.ToDecimal(txtServiceQty.Value);
                        claimService.ServiceDate        = txtServiceDate.Date;
                        claimService.ServiceDescription = txtServiceDescription.Text.Trim();
                        claimService.ServiceTypeID      = Convert.ToInt32(this.ddlInvoiceServiceType.SelectedValue);
                        claimService.UserID             = userID;
                        claimService.AdjusterID         = Convert.ToInt32(hf_serviceAdjusterID.Value);
                        claimService.Activity           = ddlActivity.SelectedItem.Text;
                        claimService.InternalComments   = txtMyComments.Text.Trim();
                        claimService.IsBillable         = cbIsBillable.Checked;
                        claimService.Billed             = false;
                        //save to db
                        claimService = repository.Save(claimService);

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

                    // diary
                    diary                  = new ClaimComment();
                    diary.ClaimID          = claimID;
                    diary.CommentDate      = DateTime.Now;
                    diary.UserId           = userID;
                    diary.ActivityType     = ddlActivity.SelectedItem.Text;
                    diary.InternalComments = txtMyComments.Text.Trim();
                    diary.CommentText      = string.Format("Service: {0}, Description: {1}, Date {2:MM/dd/yyyy}, Qty: {3:N2}, Adjuster: {4}",
                                                           ddlInvoiceServiceType.SelectedItem.Text,
                                                           claimService.ServiceDescription,
                                                           claimService.ServiceDate,
                                                           claimService.ServiceQty,
                                                           txtServiceAdjuster.Text
                                                           );
                    ClaimCommentManager.Save(diary);

                    myAdjusterID = Convert.ToInt32(claimService.AdjusterID); //Convert.ToInt32(myClaim.AdjusterID);


                    //EMAIL ADJUSTER OC 10/21/2014
                    if (myAdjusterID != 0 || myAdjusterID != null)
                    {
                        adjuster = AdjusterManager.GetAdjusterId(myAdjusterID);
                    }
                    if (cbEmailAdjuster.Checked == true)
                    {
                        try
                        {
                            notifyAdjuster(adjuster, claimService, myClaim);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text     = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }
                    //EMAIL CLIENT CONTACT OC 10/22/2014
                    if (cbEmailClient.Checked == true)              //Dont need to check if invoice Pro ID is empty becuase to get to this point, one has to exist already
                    {
                        if (Session["ComingFromAllClaims"] != null) //if the user got here straight from the all claims screen
                        {
                            profileID = Convert.ToInt32(Session["CarrierInvoiceID"]);
                        }
                        else//coming from claim detail page
                        {
                            profileID = Convert.ToInt32(Session["InvoiceProfileID"]);
                        }
                        CarrierInvoice = CarrierInvoiceProfileManager.Get(profileID);
                        try
                        {
                            notifyClientContact(CarrierInvoice, claimService, myClaim, adjuster);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text     = "Unable to send email to client contact";
                            lblMessage.CssClass = "error";
                        }
                    }
                    //EMAIL TO WHOMEVER
                    if (txtEmailTo.Text != "")
                    {
                        try
                        {
                            notifySpecifiedUser(adjuster, claimService, myClaim);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text     = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }

                    scope.Complete();
                }

                lblMessage.Text     = "Service was saved successfully.";
                lblMessage.CssClass = "ok";

                // keep edit form active
                lbtnNewClaimService_Click(null, null);

                // refresh grid
                gvClaimService.DataSource = loadClaimServices(claimID);
                gvClaimService.DataBind();
            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);

                lblMessage.Text     = "Unable to save claim service.";
                lblMessage.CssClass = "error";
            }
            //send email to adjuster
        }
        protected void addInvoiceToClaimDiary(Invoice invoice, InvoiceDetail invoiceDetail)
        {
            ClaimComment comment = null;

            // retrieve comment by reference
            //comment = ClaimCommentManager.GetLeadCommentByReferenceId(invoiceDetail.InvoiceLineID);

            if (comment == null)
                comment = new ClaimComment();

            comment.UserId = Core.SessionHelper.getUserId();
            comment.CommentDate = DateTime.Now;
            comment.ClaimID = invoice.ClaimID;
            //comment.ReferenceID = invoiceDetail.InvoiceLineID;
            comment.IsActive = true;	// active
            comment.CommentText = string.Format("<div>Invoice # {0} - {1:MM-dd-yyyy} for {2} Qty:{3:N2} Rate:{4:N2} Item Total:{5:N2}</div><div>{6}</div>",
                invoice.InvoiceNumber,
                invoiceDetail.LineDate,
                invoiceDetail.LineDescription ?? "",
                invoiceDetail.Qty ?? 0,
                invoiceDetail.Rate ?? 0,
                invoiceDetail.LineAmount ?? 0,
                invoiceDetail.Comments ?? ""
                );

            ClaimCommentManager.Save(comment);
        }
        public static string SaveClaimExpense(string expenseType, string insurerClaimId, string insurerName, int claimAdjusterId, string adjusterComapnyName, string updatedby, string commentNote, string emailTo, int carrierID, int claimID, string recipientId, string claimAdjuster, string expenseTypeName, string carrier, string idOf, string expenseQty, string expenseAmount, string expenseDate, string reimbrance)
        {
            string json = "";
            Claim objclaim = null;
            AdjusterMaster objAdjusterMaster = null;
            Leads objLeads = null;
            ClaimComment comment = null;
            ClaimExpense claimExpense = null;
            CRM.Data.Entities.LeadPolicy objLeadPolicy = null;
            int userID = SessionHelper.getUserId();
            int leadID = 0;
            int policyId = 0;
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimManager repository = new ClaimManager())
                    {
                        objclaim = new Claim();
                        objclaim.ClaimID = claimID;

                        objclaim.InsurerClaimNumber = insurerClaimId;
                        //objclaim.CarrierID = carrierID;
                        objclaim.AdjusterID = claimAdjusterId;
                        // objclaim.StatusUpdatedBy = updatedby;
                        repository.UpdateClaimStatus(objclaim);

                        // AdjusterMaster
                        objAdjusterMaster = new AdjusterMaster();
                        objAdjusterMaster.AdjusterId = claimAdjusterId;
                        //objAdjusterMaster.CompanyName = AdjusterComapnyName;
                        repository.UpdateAdjusterName(objAdjusterMaster);

                        //leads
                        leadID = repository.GetPolicyId(claimID);
                        objLeads = new Leads();
                        objLeads.LeadId = leadID;
                        objLeads.InsuredName = insurerName;
                        repository.UpdateInsurerName(objLeads);
                        //save carrier id in Lead policy
                        policyId = repository.GetLeadPolicyId(claimID);
                        objLeadPolicy = new Data.Entities.LeadPolicy();
                        objLeadPolicy.Id = policyId;
                        objLeadPolicy.CarrierID = carrierID;
                        repository.UpdateCarrierId(objLeadPolicy);

                        //add expense
                        ClaimExpenseManager objClaimExpenseManager = new ClaimExpenseManager();
                        claimExpense = new ClaimExpense();
                        claimExpense.ClaimID = claimID;
                        if (!string.IsNullOrEmpty(expenseAmount))
                        {
                            claimExpense.ExpenseAmount = Convert.ToDecimal(expenseAmount);
                        }
                        if (!string.IsNullOrEmpty(expenseDate))
                        {
                            claimExpense.ExpenseDate = Convert.ToDateTime(expenseDate);
                        }
                        claimExpense.ExpenseDescription = commentNote.Trim();
                        claimExpense.ExpenseTypeID = Convert.ToInt32(expenseType);
                        if (reimbrance == "1")
                        {
                            claimExpense.IsReimbursable = true;
                        }
                        else
                        {
                            claimExpense.IsReimbursable = false;
                        }

                        claimExpense.UserID = userID;
                        claimExpense.AdjusterID = Convert.ToInt32(claimAdjusterId);
                        if (!string.IsNullOrEmpty(expenseQty))
                        {
                            claimExpense.ExpenseQty = Convert.ToDecimal(expenseQty);
                        }
                        objClaimExpenseManager.Save(claimExpense);

                        //claim comment for add notes
                        comment = new ClaimComment();
                        comment.ClaimID = claimID;
                        comment.IsActive = true;
                        comment.UserId = Core.SessionHelper.getUserId();
                        comment.CommentDate = DateTime.Now;
                        comment.ActivityType = "Add Expense";
                        comment.CommentText = string.Format("Expense: {0}, Description: {1}, Date: {2:MM/dd/yyyy}, Amount: {3:N2}, Adjuster: {4} Qty: {5:N2}",
                                                 expenseTypeName,
                                                 commentNote.Trim(),
                                                 Convert.ToDateTime(expenseDate),
                                                 expenseAmount,
                                                 claimAdjuster,
                                                 expenseQty
                                                 );
                        ClaimCommentManager.Save(comment);

                    }
                    scope.Complete();
                }
                string[] recipId = recipientId.Split(',');
                string recipientEmailId = string.Empty;

                string[] IdofTable = idOf.Split(',');
                int index2 = 0;
                for (int index = 0; index < recipId.Length; index++)
                {
                    index2 = 0;
                    int.TryParse(recipId[index], out index2);
                    if (IdofTable[index] == "c")
                    {

                        Contact objContact = ContactManager.Get(index2);
                        if (!string.IsNullOrEmpty(objContact.Email))
                        {
                            if (recipientEmailId == "")
                            {
                                recipientEmailId = objContact.Email;
                            }
                            else
                            {
                                recipientEmailId = recipientEmailId + "," + objContact.Email;
                            }
                        }
                    }
                    else
                    {

                        AdjusterMaster objAdjuster = AdjusterManager.GetAdjusterId(index2);

                        if (!string.IsNullOrEmpty(objAdjuster.email))
                        {
                            if (recipientEmailId == "")
                            {
                                recipientEmailId = objAdjuster.email;
                            }
                            else
                            {
                                recipientEmailId = recipientEmailId + "," + objAdjuster.email;
                            }
                        }

                    }
                }
                SendExpenseEmail(expenseType, insurerClaimId, insurerName, claimAdjusterId, adjusterComapnyName, updatedby, commentNote, "", carrierID, claimID, recipientEmailId, claimAdjuster, expenseTypeName, carrier, recipId, IdofTable, expenseQty, expenseAmount, expenseDate, reimbrance);
                json = "Expense add successfully";

            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);
            }

            return json;
        }
        protected void btnSaveExpense_Click(object sender, EventArgs e)
        {
            Claim claim = null;
            Claim myClaim = null;
            ClaimExpense claimExpense = null;
            AdjusterMaster adjuster = null;
            CarrierInvoiceProfile CarrierInvoice = null;

            int clientID = SessionHelper.getClientId();
            int userID = SessionHelper.getUserId();
            int claimID = SessionHelper.getClaimID();
            int myAdjusterID = 0;
            int profileID = 0;
            int expenseTypeID = 0;
            int id = 0;

            Page.Validate("expense");
            if (!Page.IsValid)
                return;

            id = Convert.ToInt32(ViewState["ClaimExpenseID"]);

            ClaimManager cm = new ClaimManager();
            myClaim = cm.Get(claimID);

            try
            {
                expenseTypeID = Convert.ToInt32(ddlExpenseType.SelectedValue);

                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimExpenseManager repository = new ClaimExpenseManager())
                    {
                        if (id == 0) {
                            claimExpense = new ClaimExpense();
                            claimExpense.ClaimID = claimID;
                        }
                        else {
                            claimExpense = repository.Get(id);
                        }

                        // populate fields
                        if(txtExpenseAmount.Visible == false)
                        {
                            var x = Session["multiplier"].ToString();

                            double expenseAmount = Convert.ToDouble(x) * Convert.ToDouble(txtExpenseQty.ValueDecimal); //newOC 10/7/14
                            claimExpense.ExpenseAmount = Convert.ToDecimal(expenseAmount);

                            decimal d = Convert.ToDecimal(expenseAmount);
                            //Session["EmailAmount"] = "$" + Math.Round(d, 2);
                            Session["EmailAmount"] = String.Format("{0:0.00}", expenseAmount);
                           // Session["EmailAmount"] = expenseAmount;
                        }
                        else
                        {
                            claimExpense.ExpenseAmount = txtExpenseAmount.ValueDecimal;
                        }
                        claimExpense.ExpenseDate = txtExpenseDate.Date;
                        claimExpense.ExpenseDescription = txtExpenseDescription.Text.Trim();
                        claimExpense.ExpenseTypeID = expenseTypeID;
                        claimExpense.IsReimbursable = cbxExpenseReimburse.Checked;
                        claimExpense.UserID = userID;
                        claimExpense.AdjusterID = Convert.ToInt32(hf_expenseAdjusterID.Value);
                        claimExpense.ExpenseQty = txtExpenseQty.ValueDecimal;
                        claimExpense.InternalComments = txtMyComments.Text.Trim();
                        claimExpense.Billed = false;
                       // claimExpense.IsBillable = cbIsBillable.Checked;
                        // save expense
                        claimExpense = repository.Save(claimExpense);
                    }

                    // update diary entry
                    ClaimComment diary = new ClaimComment();
                    diary.ClaimID = claimID;
                    diary.CommentDate = DateTime.Now;
                    diary.UserId = userID;
                    diary.CommentText = string.Format("Expense: {0}, Description: {1}, Date: {2:MM/dd/yyyy}, Amount: {3:N2}, Adjuster: {4} Qty: {5:N2}",
                                                ddlExpenseType.SelectedItem.Text,
                                                claimExpense.ExpenseDescription,
                                                claimExpense.ExpenseDate,
                                                claimExpense.ExpenseAmount,
                                                txtExpenseAdjuster.Text,
                                                claimExpense.ExpenseQty
                                                );
                    ClaimCommentManager.Save(diary);

                    // 2014-05-02 apply rule
                    using (SpecificExpenseTypePerCarrier ruleEngine = new SpecificExpenseTypePerCarrier())
                    {
                        claim = new Claim();
                        claim.ClaimID = claimID;
                        RuleException ruleException = ruleEngine.TestRule(clientID, claim, expenseTypeID);

                        if (ruleException != null) {
                            ruleException.UserID = Core.SessionHelper.getUserId();
                            ruleEngine.AddException(ruleException);
                            CheckSendMail(ruleException);
                        }
                    }
                    myAdjusterID = Convert.ToInt32(claimExpense.AdjusterID); //Convert.ToInt32(myClaim.AdjusterID);
                    //EMAIL ADJUSTER OC 10/22/2014
                    if (myAdjusterID != 0 || myAdjusterID != null)
                    {
                        adjuster = AdjusterManager.GetAdjusterId(myAdjusterID);
                    }
                    if (cbEmailAdjuster.Checked == true)
                    {
                        try
                        {
                            notifyAdjuster(adjuster, claimExpense, myClaim);

                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }
                    //EMAIL CLIENT CONTACT OC 10/22/2014
                    if (cbEmailClient.Checked == true) //Dont need to check if invoice Pro ID is empty becuase to get to this point, one has to exist already
                    {
                        if (Session["ComingFromAllClaims"] != null) //if the user got here straight from the all claims screen
                        {
                            profileID = Convert.ToInt32(Session["CarrierInvoiceID"]);
                        }
                        else//coming from claim detail page
                        {
                            profileID = Convert.ToInt32(Session["InvoiceProfileID"]);
                        }
                        CarrierInvoice = CarrierInvoiceProfileManager.Get(profileID);
                        try
                        {
                              notifyClientContact(CarrierInvoice, claimExpense, myClaim, adjuster);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "Unable to send email to client contact";
                            lblMessage.CssClass = "error";
                        }

                    }
                    //EMAIL TO WHOMEVER OC 10/22/2014
                    if (txtEmailTo.Text != "")
                    {

                        try
                        {
                             notifySpecifiedUser(adjuster, claimExpense, myClaim);
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = "Unable to send email to adjuster";
                            lblMessage.CssClass = "error";
                        }
                    }

                    // complete transaction
                    scope.Complete();
                }

                lblMessage.Text = "Expense saved successfully.";
                lblMessage.CssClass = "ok";

                // refresh grid
                gvExpense.DataSource = loadExpenses(claimID);
                gvExpense.DataBind();

                // keep edit form active
                lbtnNewExpense_Click(null, null);
                lblAmount.Text = "";
                lblAmount.Visible = false;
                txtExpenseAmount.Visible = true;
            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);

                lblMessage.Text = "Unable to save claim expense.";
                lblMessage.CssClass = "error";
            }
        }
        public static string SaveClaimStatus(int claimStatus, string insurerClaimId, string insurerName, int claimAdjusterId, string adjusterComapnyName, string updatedby, string commentNote, string emailTo, int carrierID, int claimID, string recipientId, string claimAdjuster, string claimStatusName, string carrier, string idOf)
        {
            string json = "";
            Claim objclaim = null;
            AdjusterMaster objAdjusterMaster = null;
            Leads objLeads = null;
            CRM.Data.Entities.LeadPolicy objLeadPolicy = null;
            ClaimComment comment = null;
            Client objClient = null;
            int userID = SessionHelper.getUserId();
            int leadID = 0;
            int policyId = 0;
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (ClaimManager repository = new ClaimManager())
                    {
                        objclaim = new Claim();
                        objclaim.ClaimID = claimID;
                        objclaim.StatusID = claimStatus;
                        objclaim.InsurerClaimNumber = insurerClaimId;
                        //objclaim.CarrierID = carrierID;
                        objclaim.AdjusterID = claimAdjusterId;
                        objclaim.StatusUpdatedBy = updatedby;
                        objclaim.StatusCommentNote = commentNote;
                        //objclaim.StatusEmailTo = EmailTo;
                        repository.UpdateClaimStatus(objclaim);

                        // AdjusterMaster
                        objAdjusterMaster = new AdjusterMaster();
                        objAdjusterMaster.AdjusterId = claimAdjusterId;
                        //objAdjusterMaster.CompanyName = AdjusterComapnyName;
                        repository.UpdateAdjusterName(objAdjusterMaster);

                        //leads
                        leadID = repository.GetPolicyId(claimID);
                        objLeads = new Leads();
                        objLeads.LeadId = leadID;
                        objLeads.InsuredName = insurerName;
                        repository.UpdateInsurerName(objLeads);
                        //save carrier id in Lead policy
                        policyId = repository.GetLeadPolicyId(claimID);
                        objLeadPolicy = new Data.Entities.LeadPolicy();
                        objLeadPolicy.Id = policyId;
                        objLeadPolicy.CarrierID = carrierID;
                        repository.UpdateCarrierId(objLeadPolicy);
                        //claim comment for add notes
                        comment = new ClaimComment();
                        comment.ClaimID = claimID;
                        comment.IsActive = true;
                        comment.UserId = Core.SessionHelper.getUserId();
                        comment.CommentDate = DateTime.Now;
                        comment.ActivityType = "Status Changed";
                        comment.CommentText = commentNote.Trim();
                        ClaimCommentManager.Save(comment);

                        //client company name
                        //Client c = ClaimsManager.GetClientByUserId(SessionHelper.getUserId());
                        //c.BusinessName = AdjusterComapnyName;
                        //ClaimsManager.SaveClient(c);

                    }
                    scope.Complete();
                }
                string[] recipId = recipientId.Split(',');
                string recipientEmailId = string.Empty;

                string[] idofTable = idOf.Split(',');
                int index2 = 0;
                for (int index = 0; index < recipId.Length; index++)
                {
                    index2 = 0;
                    int.TryParse(recipId[index], out index2);
                    if (idofTable[index] == "c")
                    {

                        Contact objContact = ContactManager.Get(index2);
                        if (!string.IsNullOrEmpty(objContact.Email))
                        {
                            if (recipientEmailId == "")
                            {
                                recipientEmailId = objContact.Email;
                            }
                            else
                            {
                                recipientEmailId = recipientEmailId + "," + objContact.Email;
                            }
                        }
                    }
                    else
                    {

                        AdjusterMaster objAdjuster = AdjusterManager.GetAdjusterId(index2);

                        if (!string.IsNullOrEmpty(objAdjuster.email))
                        {
                            if (recipientEmailId == "")
                            {
                                recipientEmailId = objAdjuster.email;
                            }
                            else
                            {
                                recipientEmailId = recipientEmailId + "," + objAdjuster.email;
                            }
                        }

                    }
                }
                if (!string.IsNullOrEmpty(recipientEmailId))
                {
                    notifyUser(claimStatus, insurerClaimId, insurerName, claimAdjusterId, adjusterComapnyName, updatedby, commentNote, "", carrierID, claimID, recipientEmailId, claimAdjuster, claimStatusName, carrier, recipId, idofTable);
                }
                json = "Status save successfully";

            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);
            }

            return json;
        }
示例#18
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);
            }
        }
        protected void btnDocumentsSave_Click(object sender, EventArgs e)
        {
            for (int rowCount = 0; rowCount < gvSearchResult.Rows.Count; rowCount++)
            {
                CheckBox box = (CheckBox)gvSearchResult.Rows[rowCount].Cells[0].Controls[1];
                if (box.Checked)
                {
                    int commentID = 0;
                    ClaimComment comment = null;

                    comment = new ClaimComment();
                    comment.ClaimID = this.claimID;
                    comment.IsActive = true;
                    comment.UserId = Core.SessionHelper.getUserId();
                    comment.CommentDate = DateTime.Now;

                    string serviceUrl = ConfigurationManager.AppSettings["importServiceUrl"];
                    serviceUrl = serviceUrl + "/" + "ExportNotes?commentId=" + commentID;
                    Common.SendRequest(serviceUrl);
                    if (comment != null && comment.ClaimID > 0)
                    {
                        comment.CommentText = gvSearchResult.Rows[rowCount].Cells[2].Text;

                        try
                        {
                            ClaimCommentManager.Save(comment);
                            EmailMessage msg = instanceResults.Items[rowCount] as EmailMessage;
                            if (msg.HasAttachments)
                            {
                                foreach (Attachment attachment in msg.Attachments)
                                {
                                    if (attachment is FileAttachment)
                                    {
                                        FileAttachment fileAttachment = attachment as FileAttachment;

                                        // Load the attachment into a file.
                                        // This call results in a GetAttachment call to EWS.
                                        string tempName = HttpContext.Current.Server.MapPath(String.Format("~\\Temp\\{0}", fileAttachment.Name));
                                        fileAttachment.Load(tempName);
                                        ClaimEdit.saveFile(claimID, fileAttachment.Name, "Attachment from email " + msg.Subject, 6);
                                        File.Delete(tempName);
                                    }
                                }
                            }
                            lblErrorMSg.Text = "Email(s) Saved successfully";
                            lblErrorMSg.Visible = true;
                        }
                        catch (Exception ex)
                        {
                            lblErrorMSg.Text = "Mail not saved!";
                            lblErrorMSg.CssClass = "error";
                            Core.EmailHelper.emailError(ex);
                        }
                    }
                }
            }
        }