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); } }
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 void dataBind(int claimID) { gvComments.DataSource = ClaimCommentManager.GetAll(claimID); gvComments.DataBind(); bindHistoricalComments(); }
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); } } } } }
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); } } }
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); } }
static protected void exportClaimLog(int claimID, string claimNumber) { List <ClaimCommented> claimComments = ClaimCommentManager.GetAll(claimID); if (claimComments == null || claimComments.Count == 0) { return; } // create table 2 cells PdfPTable ptable = new PdfPTable(new float[] { 20, 80 }); ptable.WidthPercentage = 90; addClaimComments(ptable, claimComments, claimNumber); doc.Add(ptable); }
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 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 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"; } }