public IHttpActionResult getStatusMaster(int Id) { try { StatusMaster statusMaster = _PermissionsInboundService.GetStatusMasterById(Id); var _StatusMaster = new { Id = statusMaster.Id, Status = statusMaster.Status }; return(Json(_StatusMaster)); } catch (ACSException ex) { _ILog.LogException("", Severity.ProcessingError, "AssetMasterController.cs", "getStatusMaster", ex); return(Json(ex.InnerException)); } catch (Exception ex) { _ILog.LogException("", Severity.ProcessingError, "AssetMasterController.cs", "getStatusMaster", ex); return(Json(ex.InnerException)); } return(null); }
public IHttpActionResult DeleteStatusMaster(StatusMaster _StatusMaster) { string status = string.Empty; try { StatusMaster statusMaster = _PermissionsInboundService.GetStatusMasterById(_StatusMaster.Id); statusMaster.Deactivate = "Y"; statusMaster.DeactivateBy = _StatusMaster.EnteredBy; statusMaster.DeactivateDate = DateTime.Now; _PermissionsInboundService.UpdateStatusMaster(statusMaster); status = _localizationService.GetResource("Master.API.Success.Message"); } catch (ACSException ex) { _ILog.LogException("", Severity.ProcessingError, "AssetMasterController.cs", "DeleteStatusMaster", ex); status = ex.InnerException.Message; } catch (Exception ex) { _ILog.LogException("", Severity.ProcessingError, "AssetMasterController.cs", "DeleteStatusMaster", ex); status = ex.InnerException.Message; } return(Json(status)); }
public ActionResult DeleteConfirmed(int id) { StatusMaster statusMaster = db.StatusMasters.Find(id); db.StatusMasters.Remove(statusMaster); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(int id) { StatusMaster statusMaster = await db.StatusMasters.FindAsync(id); db.StatusMasters.Remove(statusMaster); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "statuscode,status")] StatusMaster statusMaster) { if (ModelState.IsValid) { db.Entry(statusMaster).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(statusMaster)); }
public void insertStatus(int id, string name) { DataClasses1DataContext dc = new DataClasses1DataContext(); StatusMaster status = new StatusMaster(); status.StatusID = id; status.StatusName = name; dc.StatusMasters.InsertOnSubmit(status); dc.SubmitChanges(); }
public async Task <ActionResult> Edit([Bind(Include = "ID,Name")] StatusMaster statusMaster) { if (ModelState.IsValid) { db.Entry(statusMaster).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(statusMaster)); }
public ActionResult Create([Bind(Include = "statuscode,status")] StatusMaster statusMaster) { if (ModelState.IsValid) { db.StatusMasters.Add(statusMaster); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(statusMaster)); }
public void InsertStatusMaster(StatusMaster _StatusMaster) { _StatusMaster.Deactivate = "N"; _StatusMaster.Status = _StatusMaster.Status.Trim(); _StatusMaster.EntryDate = DateTime.Now; _StatusMaster.ModifiedBy = null; _StatusMaster.ModifiedDate = null; _StatusMaster.DeactivateBy = null; _StatusMaster.DeactivateDate = null; _StatusMasterService.Insert(_StatusMaster); }
public void InsertOrUpdate(StatusMaster statusmaster) { if (statusmaster.StatusId == default(int)) { // New entity context.StatusMaster.Add(statusmaster); } else { // Existing entity context.Entry(statusmaster).State = EntityState.Modified; } }
public async Task <ActionResult> Create([Bind(Include = "ID,Name")] StatusMaster statusMaster) { if (ModelState.IsValid) { db.StatusMasters.Add(statusMaster); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(statusMaster)); }
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e) { StatusMaster leadStatus = null; int statusId = 0; if (e.CommandName.Equals("DoEdit")) { statusId = Convert.ToInt32(e.CommandArgument); leadStatus = StatusManager.GetStatusId(statusId); if (leadStatus != null) { hdId.Value = statusId.ToString(); txtStatus.Text = leadStatus.StatusName; if (leadStatus.ReminderID != null) { ddlReminder.SelectedValue = leadStatus.ReminderID.ToString(); } cbxIsCountable.Checked = leadStatus.isCountable ?? false; cbxIsCountAsOpen.Checked = leadStatus.isCountAsOpen ?? false; pnlGrid.Visible = false; pnlEdit.Visible = true; } } else if (e.CommandName.Equals("DoDelete")) { // In Case of delete try { var status = StatusManager.GetStatusId(Convert.ToInt32(e.CommandArgument)); status.Status = false; StatusManager.Save(status); btnCancel_Click(null, null); lblSave.Text = "Record Deleted Sucessfully."; lblSave.Visible = true; } catch (Exception ex) { lblError.Text = "Record Not Deleted."; lblError.Visible = true; Core.EmailHelper.emailError(ex); } } }
// GET: StatusMasters/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StatusMaster statusMaster = await db.StatusMasters.FindAsync(id); if (statusMaster == null) { return(HttpNotFound()); } return(View(statusMaster)); }
// GET: StatusMasters/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } StatusMaster statusMaster = db.StatusMasters.Find(id); if (statusMaster == null) { return(HttpNotFound()); } return(View(statusMaster)); }
public string DuplicityCheckStatusMaster(StatusMaster _StatusMaster) { var dupes = _StatusMasterService.Table.Where(x => x.Status == _StatusMaster.Status && x.Deactivate == "N" && (_StatusMaster.Id != 0 ? x.Id : 0) != (_StatusMaster.Id != 0 ? _StatusMaster.Id : 1)).FirstOrDefault(); if (dupes != null) { return("N"); } else { return("Y"); } }
public static string CheckCompulsoryStatusColumn(StatusMaster status) { if (string.IsNullOrEmpty(status.StatusName)) { return(QueryResource.StatusNameMissing); } else if (status.StatusID == 0) { return(QueryResource.StatusIdMissing); } else { return(QueryResource.AllFieldsPresent); } }
public void AddStatus(StatusMaster status) { CompanyDBDataContext dc = new CompanyDBDataContext(); string dataValidate = ValidationHelper.CheckCompulsoryStatusColumn(status); if (dataValidate != QueryResource.AllFieldsPresent) { throw new Exception(dataValidate); } else { dc.StatusMasters.InsertOnSubmit(status); dc.SubmitChanges(); } }
public static StatusMaster Save(StatusMaster objStatus) { if (objStatus.StatusId == 0) { //objProducer.InsertBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name); objStatus.InsertDate = DateTime.Now; objStatus.InsertMachineInfo = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); DbContextHelper.DbContext.Add(objStatus); } //secUser.UpdatedBy = Convert.ToInt32(HttpContext.Current.User.Identity.Name); objStatus.UpdateMachineIfo = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); objStatus.UpdateDate = DateTime.Now; DbContextHelper.DbContext.SaveChanges(); return(objStatus); }
public IHttpActionResult InsertStatusMaster(StatusMaster _StatusMaster) { string status = ""; try { status = _PermissionsInboundService.DuplicityCheckStatusMaster(_StatusMaster); if (status == "Y") { if (_StatusMaster.Id == 0) { _PermissionsInboundService.InsertStatusMaster(_StatusMaster); status = _localizationService.GetResource("Master.API.Success.Message"); } else { StatusMaster atatusMaster = _PermissionsInboundService.GetStatusMasterById(_StatusMaster.Id); atatusMaster.Status = _StatusMaster.Status; atatusMaster.ModifiedBy = _StatusMaster.EnteredBy; atatusMaster.ModifiedDate = DateTime.Now; _PermissionsInboundService.UpdateStatusMaster(atatusMaster); status = _localizationService.GetResource("Master.API.Success.Message"); } } else { status = "Duplicate"; } } catch (ACSException ex) { _ILog.LogException("", Severity.ProcessingError, "AssetMasterController.cs", "InsertStatusMaster", ex); status = ex.InnerException.Message; } catch (Exception ex) { _ILog.LogException("", Severity.ProcessingError, "AssetMasterController.cs", "InsertStatusMaster", ex); status = ex.InnerException.Message; } return(Json(status)); }
private void copyMasterStatus(int sourceClientID, int targetClientID, int clientUserID) { List <StatusMaster> statuses = null; // get list of status from model statuses = StatusManager.GetAll(sourceClientID); foreach (StatusMaster status in statuses) { StatusMaster newStatusMaster = new StatusMaster(); newStatusMaster.clientID = targetClientID; newStatusMaster.InsertBy = clientUserID; newStatusMaster.InsertDate = DateTime.Now; newStatusMaster.isCountable = status.isCountable; newStatusMaster.Status = status.Status; newStatusMaster.StatusName = status.StatusName; newStatusMaster.UpdateBy = clientUserID; newStatusMaster.UpdateDate = DateTime.Now; newStatusMaster.isCountAsOpen = status.isCountAsOpen; StatusManager.Save(newStatusMaster); } }
public NotificationList PageLoad_NotificationsList(Search_Notification obj) { NotificationList objR = new NotificationList(); NotificationListDataManager objDM = new NotificationListDataManager(); DataSet ds = objDM.GetPageLoad_NotificationsList(obj); if (ds != null && ds.Tables.Count > 0) { int tblIndx = -1; #region "Country List" tblIndx++; if (ds.Tables.Count > tblIndx && ds.Tables[tblIndx] != null && ds.Tables[tblIndx].Rows.Count > 0) { List <Country> CountryList = new List <Country>(); foreach (DataRow dr in ds.Tables[tblIndx].Rows) { Country objCountry = new Country(); objCountry.CountryId = Convert.ToInt64(dr["CountryId"]); objCountry.CountryCode = Convert.ToString(dr["CountryCode"]); objCountry.Name = Convert.ToString(dr["Country"]); CountryList.Add(objCountry); } objR.CountryList = CountryList; } #endregion #region "Status List" tblIndx++; if (ds.Tables.Count > tblIndx && ds.Tables[tblIndx] != null && ds.Tables[tblIndx].Rows.Count > 0) { List <StatusMaster> StatusList = new List <StatusMaster>(); foreach (DataRow dr in ds.Tables[tblIndx].Rows) { StatusMaster objStatus = new StatusMaster(); objStatus.StatusId = Convert.ToInt32(dr["StatusId"]); objStatus.Status = Convert.ToString(dr["Status"]); StatusList.Add(objStatus); } objR.StatusList = StatusList; } #endregion #region "Action List" tblIndx++; if (ds.Tables.Count > tblIndx && ds.Tables[tblIndx] != null && ds.Tables[tblIndx].Rows.Count > 0) { List <ActionMaster> ActionList = new List <ActionMaster>(); foreach (DataRow dr in ds.Tables[tblIndx].Rows) { ActionMaster objAction = new ActionMaster(); objAction.ActionId = Convert.ToInt32(dr["ActionId"]); objAction.Action = Convert.ToString(dr["Action"]); ActionList.Add(objAction); } objR.ActionList = ActionList; } #endregion #region "Action Status List" tblIndx++; if (ds.Tables.Count > tblIndx && ds.Tables[tblIndx] != null && ds.Tables[tblIndx].Rows.Count > 0) { List <Status> StatusList = new List <Status>(); foreach (DataRow dr in ds.Tables[tblIndx].Rows) { Status objStatus = new Status(); objStatus.StatusId = Convert.ToInt32(dr["StatusId"]); objStatus.StatusName = Convert.ToString(dr["Status"]); StatusList.Add(objStatus); } objR.ActionStatusList = StatusList; } #endregion #region "Notification List" tblIndx++; if (ds.Tables.Count > tblIndx && ds.Tables[tblIndx] != null && ds.Tables[tblIndx].Rows.Count > 0) { List <BusinessObjects.Notification.Notification> ItemsList = new List <BusinessObjects.Notification.Notification>(); foreach (DataRow dr in ds.Tables[tblIndx].Rows) { BusinessObjects.Notification.Notification objItems = new BusinessObjects.Notification.Notification(); objItems.NotificationId = Convert.ToInt64(dr["NotificationId"]); objItems.ItemNumber = Convert.ToInt64(dr["ItemNumber"]); objItems.NotificationNumber = Convert.ToString(dr["NotificationNumber"]); objItems.NotificationDate = Convert.ToString(dr["DateOfNotification"]); objItems.FinalDateOfComments = Convert.ToString(dr["FinalDateOfComment"]); objItems.Country = Convert.ToString(dr["Country"]); objItems.Title = Convert.ToString(dr["Title"]); objItems.MailCount = Convert.ToInt32(dr["MailCount"]); objItems.ResponseCount = Convert.ToInt32(dr["ResponseCount"]); objItems.Actions = Convert.ToString(dr["Actions"]); objItems.MeetingDate = Convert.ToString(dr["MeetingDate"]); objItems.IsInMeeting = Convert.ToBoolean(dr["IsInMeeting"]); ItemsList.Add(objItems); } objR.Notifications = ItemsList; } #endregion #region "Notification Count" tblIndx++; if (ds.Tables.Count > tblIndx && ds.Tables[tblIndx] != null && ds.Tables[tblIndx].Rows.Count > 0) { objR.TotalCount = Convert.ToInt64(ds.Tables[tblIndx].Rows[0]["TotalCount"]); } #endregion #region "Notification Process Dots Color & Tooltip Text" tblIndx++; if (ds.Tables.Count > tblIndx && ds.Tables[tblIndx] != null && ds.Tables[tblIndx].Rows.Count > 0) { List <NotificationProcessDot> NPSList = new List <NotificationProcessDot>(); foreach (DataRow dr in ds.Tables[tblIndx].Rows) { NotificationProcessDot objNPS = new NotificationProcessDot(); objNPS.NotificationId = Convert.ToInt64(dr["NotificationId"]); objNPS.ColorCode = Convert.ToString(dr["ColorCode"]); objNPS.TooltipText = Convert.ToString(dr["TooltipText"]); objNPS.Sequence = Convert.ToInt32(dr["Sequence"]); NPSList.Add(objNPS); } objR.NotificationProcessDots = NPSList; } #endregion #region "Notification Action Dots Color & Tooltip Text" tblIndx++; if (ds.Tables.Count > tblIndx && ds.Tables[tblIndx] != null && ds.Tables[tblIndx].Rows.Count > 0) { List <NotificationActionDot> NASList = new List <NotificationActionDot>(); foreach (DataRow dr in ds.Tables[tblIndx].Rows) { NotificationActionDot objNAS = new NotificationActionDot(); objNAS.NotificationId = Convert.ToInt64(dr["NotificationId"]); objNAS.ColorCode = Convert.ToString(dr["ColorCode"]); objNAS.TooltipText = Convert.ToString(dr["TooltipText"]); objNAS.Sequence = Convert.ToInt32(dr["Sequence"]); NASList.Add(objNAS); } objR.NotificationActionDots = NASList; } #endregion } return(objR); }
public ActionResult AjaxAdd(string targetPage, FormCollection collection) { object _genericObject = null; string id = collection["Id"]; string msg = ""; bool modelIsValid = false; switch (targetPage) { case "FieldType": var FieldType = FieldTypeContext.Collection().Where(x => x.Id == id).FirstOrDefault(); if (FieldType != null) { FieldType.Type = collection["Type"]; FieldType.Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]); FieldType.ModifiedAt = DateTime.Now; FieldTypeContext.Update(FieldType); } else { FieldType fieldType = new FieldType() { Type = collection["Type"], Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]) }; modelIsValid = TryValidateModel(fieldType); if (modelIsValid) { FieldTypeContext.Insert(fieldType); } else { _genericObject = fieldType; } } FieldTypeContext.Commit(); break; case "Organisation": var Organisation = OrganisationContext.Collection().Where(x => x.Id == id).FirstOrDefault(); if (Organisation != null) { switch (collection["Type"]) { case "0": Organisation.Type = OrganisationType.Operator; break; case "1": Organisation.Type = OrganisationType.DGH; break; case "2": Organisation.Type = OrganisationType.ERCommittee; break; default: Organisation.Type = OrganisationType.Others; break; } Organisation.Name = collection["Name"]; Organisation.Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]); Organisation.ModifiedAt = DateTime.Now; OrganisationContext.Update(Organisation); } else { Organisation organisation = new Organisation(collection["Name"], collection["Type"]); organisation.Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]); modelIsValid = TryValidateModel(organisation); if (TryValidateModel(modelIsValid)) { OrganisationContext.Insert(organisation); OrganisationContext.Commit(); } else { _genericObject = organisation; } } OrganisationContext.Commit(); break; case "User": UserAccount userAccount = new UserAccount() { EmailID = collection["user.EmailID"], FirstName = collection["user.FirstName"], LastName = collection["user.LastName"], OrganisationId = collection["user.OrganisationId"] }; modelIsValid = TryValidateModel(userAccount); if (modelIsValid && null != collection["user.OrganisationId"]) { UserAccountContext.Insert(userAccount); UserAccountContext.Commit(); } else { _genericObject = new UserOrganisationViewModel() { user = userAccount, organisations = OrganisationContext.Collection() }; modelIsValid = false; } break; case "UHCProductionMethod": var UHCProductionMethod = UHCProductionMethodContext.Collection().Where(x => x.Id == id).FirstOrDefault(); if (UHCProductionMethod != null) { UHCProductionMethod.Name = collection["Name"]; UHCProductionMethod.Description = collection["Description"]; UHCProductionMethod.Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]); UHCProductionMethod.ModifiedAt = DateTime.Now; UHCProductionMethodContext.Update(UHCProductionMethod); } else { UHCProductionMethod uHCProductionMethod = new UHCProductionMethod() { Name = collection["Name"], Description = collection["Description"], Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]) }; modelIsValid = TryValidateModel(uHCProductionMethod); if (modelIsValid) { UHCProductionMethodContext.Insert(uHCProductionMethod); } else { _genericObject = uHCProductionMethod; } } UHCProductionMethodContext.Commit(); break; case "ERScreeningInstitute": var ERScreeningInstitute = ERScreeningInstituteContext.Collection().Where(x => x.Id == id).FirstOrDefault(); if (ERScreeningInstitute != null) { ERScreeningInstitute.InstituteName = collection["InstituteName"]; ERScreeningInstitute.ContactPerson = collection["ContactPerson"]; ERScreeningInstitute.Address = collection["Address"]; ERScreeningInstitute.EmailID = collection["EmailID"]; ERScreeningInstitute.Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]); ERScreeningInstitute.ModifiedAt = DateTime.Now; ERScreeningInstituteContext.Update(ERScreeningInstitute); } else { ERScreeningInstitute ERScreeningInstitute1 = new ERScreeningInstitute() { InstituteName = collection["InstituteName"], ContactPerson = collection["ContactPerson"], Address = collection["Address"], EmailID = collection["EmailID"], Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]) }; modelIsValid = TryValidateModel(ERScreeningInstitute1); if (modelIsValid) { ERScreeningInstituteContext.Insert(ERScreeningInstitute1); } else { _genericObject = ERScreeningInstitute1; } } ERScreeningInstituteContext.Commit(); break; case "StatusMaster": var Status = StatusMasterContext.Collection().Where(x => x.Id == id).FirstOrDefault(); if (Status != null) { Status.CustStatusId = collection["CustStatusId"]; Status.Status = collection["Status"]; Status.Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]); Status.ModifiedAt = DateTime.Now; StatusMasterContext.Update(Status); } else { StatusMaster statusMaster = new StatusMaster() { CustStatusId = collection["CustStatusId"], Status = collection["Status"], Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]) }; modelIsValid = TryValidateModel(statusMaster); if (modelIsValid) { StatusMasterContext.Insert(statusMaster); } else { _genericObject = statusMaster; } } StatusMasterContext.Commit(); break; case "Department": var Dept = DepartmentContext.Collection().Where(x => x.Id == id).FirstOrDefault(); if (Dept != null) { Dept.DeptName = collection["DeptName"]; Dept.SubDeptName = collection["SubDeptName"]; Dept.Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]); Dept.ModifiedAt = DateTime.Now; DepartmentContext.Update(Dept); } else { DepartmentType department = new DepartmentType() { DeptName = collection["DeptName"], SubDeptName = collection["SubDeptName"], Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]) }; modelIsValid = TryValidateModel(department); if (modelIsValid) { DepartmentContext.Insert(department); } else { _genericObject = department; } } DepartmentContext.Commit(); break; case "ERTechniques": var ertechnique = ERTechniquesContext.Collection().Where(x => x.Id == id).FirstOrDefault(); EORTechniqueType eORTechniqueType; if (ertechnique != null) { switch (collection["Method"]) { case "0": ertechnique.Method = ImplementaionType.EORMethod; break; case "1": ertechnique.Method = ImplementaionType.IORRecoveryMethod; break; case "2": ertechnique.Method = ImplementaionType.EGRMethod; break; case "3": ertechnique.Method = ImplementaionType.IGRRecoveryMethod; break; case "4": ertechnique.Method = ImplementaionType.UHCMethod; break; default: break; } ertechnique.TechniqueName = collection["TechniqueName"]; Enum.TryParse(collection["TechniqueType"], true, out eORTechniqueType); ertechnique.TechniqueType = eORTechniqueType; ertechnique.Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]); ertechnique.Status = collection["Status"]; ertechnique.ModifiedAt = DateTime.Now; ERTechniquesContext.Update(ertechnique); } else { ERTechniques eRTechniques = new ERTechniques(); switch (collection["Method"]) { case "0": eRTechniques.Method = ImplementaionType.EORMethod; break; case "1": eRTechniques.Method = ImplementaionType.IORRecoveryMethod; break; case "2": eRTechniques.Method = ImplementaionType.EGRMethod; break; case "3": eRTechniques.Method = ImplementaionType.IGRRecoveryMethod; break; case "4": eRTechniques.Method = ImplementaionType.UHCMethod; break; default: return(Content("Error")); } eRTechniques.TechniqueName = collection["TechniqueName"]; Enum.TryParse(collection["TechniqueType"], true, out eORTechniqueType); ertechnique.TechniqueType = eORTechniqueType; eRTechniques.Is_Active = Convert.ToBoolean(collection["Is_Active"].Split(',')[0]); eRTechniques.Status = collection["Status"]; modelIsValid = TryValidateModel(eRTechniques); if (modelIsValid) { ERTechniquesContext.Insert(eRTechniques); } else { _genericObject = eRTechniques; } } ERTechniquesContext.Commit(); break; default: return(Content("Error")); } if (_genericObject == null) { return(Content("Success")); } else { return(View(targetPage, _genericObject)); } }
protected void UploadTemplate1() { // original format designed by Vivek int adjusterID = 0; lblSave.Text = string.Empty; lblSave.Visible = false; lblError.Text = string.Empty; lblError.Visible = false; lblMessage.Text = string.Empty; lblMessage.Visible = false; // 2013-02-09 tortega -- Added data validation prior to import. File is not aborted in the event of incorrect data. string str = null; int clientID = Core.SessionHelper.getClientId(); // assume homeowner int policyType = 1; DateTime DateSubmitted = DateTime.Now; try { if (FileUpload1.HasFile) { string ext = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName); string ActualFileName = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(@"\") + 1); string FileNameWithoutExt = ActualFileName.Replace(ext, ""); if (ext == ".csv") { if (!Directory.Exists(Server.MapPath("~//CSVLoad//"))) { Directory.CreateDirectory(Server.MapPath("~//CSVLoad//")); } FileUpload1.SaveAs(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName)); DataTable table = CSVReader.ReadCSVFile(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName), true); using (TransactionScope scope = new TransactionScope()) { Leads objLead = null; for (int i = 0; i < table.Rows.Count; i++) { objLead = new Leads(); objLead.OriginalLeadDate = DateTime.Now; objLead.UserId = Convert.ToInt32(Session["UserId"]); if (table.Rows[i]["DateSubmitted"] != string.Empty) { DateTime.TryParse(table.Rows[i]["DateSubmitted"].ToString(), out DateSubmitted); objLead.DateSubmitted = DateSubmitted; } str = table.Rows[i]["LFUUID"].ToString(); if (str.Length > 50) objLead.LFUUID = table.Rows[i]["LFUUID"].ToString().Substring(0, 50); else objLead.LFUUID = table.Rows[i]["LFUUID"].ToString(); if (table.Rows[i]["Original Lead Date"] != string.Empty) { objLead.OriginalLeadDate = Convert.ToDateTime(table.Rows[i]["Original Lead Date"]); } if (table.Rows[i]["Last Name"] != string.Empty) { str = table.Rows[i]["Last Name"].ToString(); if (str.Length > 50) objLead.ClaimantLastName = table.Rows[i]["Last Name"].ToString().Substring(0, 50); else objLead.ClaimantLastName = table.Rows[i]["Last Name"].ToString(); } if (table.Rows[i]["First Name"] != string.Empty) { str = table.Rows[i]["First Name"].ToString(); if (str.Length > 50) objLead.ClaimantFirstName = table.Rows[i]["First Name"].ToString().Substring(0, 50); else objLead.ClaimantFirstName = table.Rows[i]["First Name"].ToString(); } if (table.Rows[i]["Email Address"] != string.Empty) { str = table.Rows[i]["Email Address"].ToString(); if (str.Length > 100) objLead.EmailAddress = str.Substring(0, 100); else objLead.EmailAddress = str; } if (table.Rows[i]["Secondary Email"] != string.Empty) { str = table.Rows[i]["Secondary Email"].ToString(); if (str.Length > 100) objLead.SecondaryEmail = str.Substring(0, 100); else objLead.SecondaryEmail = str; } if (table.Rows[i]["Adjuster"] != string.Empty) { string adjusterName = table.Rows[i]["Adjuster"].ToString(); AdjusterMaster adjuster = null; if (!string.IsNullOrEmpty(adjusterName)) { adjuster = AdjusterManager.GetByAdjusterName(adjusterName.Trim()); if (adjuster.AdjusterId == 0) { // add adjuster adjuster = new AdjusterMaster(); adjuster.Status = true; adjuster.AdjusterName = adjusterName.Trim(); adjuster.ClientId = clientID; adjuster.InsertBy = objLead.UserId; adjuster.InsertDate = DateTime.Now; adjuster.isEmailNotification = true; adjuster = AdjusterManager.Save(adjuster); } adjusterID = adjuster.AdjusterId; } } if (table.Rows[i]["Lead Source"] != string.Empty) { string sourceName = table.Rows[i]["Lead Source"].ToString(); var id = LeadSourceManager.GetByLeadSourceName(sourceName); if (id.LeadSourceId > 0) objLead.LeadSource = id.LeadSourceId; else { // add source LeadSourceMaster leadSource = new LeadSourceMaster(); if (clientID > 0) leadSource.ClientId = clientID; leadSource.InsertBy = Core.SessionHelper.getUserId(); leadSource.InsertDate = DateTime.Now; leadSource.LeadSourceName = sourceName.Length > 100 ? sourceName.Substring(0, 100) : sourceName; leadSource.Status = true; LeadSourceMaster newLeadSource = LeadSourceManager.Save(leadSource); objLead.LeadSource = newLeadSource.LeadSourceId; } } if (table.Rows[i]["Primary Producer"] != string.Empty) { var id = ProducerManager.GetByProducerName(table.Rows[i]["Primary Producer"].ToString()); if (id != null && id.ProducerId > 0) objLead.PrimaryProducerId = id.ProducerId; else { ProducerMaster producer = AddProducer(objLead, table.Rows[i]["Primary Producer"].ToString()); objLead.PrimaryProducerId = producer.ProducerId; } } if (table.Rows[i]["Secondary Producer"] != string.Empty) { var id = SecondaryProducerManager.GetBySecondaryProducerName(table.Rows[i]["Secondary Producer"].ToString()); if (id != null && id.SecondaryProduceId > 0) objLead.SecondaryProducerId = id.SecondaryProduceId; else { ProducerMaster producer = AddProducer(objLead, table.Rows[i]["Secondary Producer"].ToString()); objLead.SecondaryProducerId = producer.ProducerId; } } if (table.Rows[i]["Inspector Name"] != string.Empty) { var id = InspectorManager.GetByName(table.Rows[i]["Inspector Name"].ToString()); if (id != null && id.InspectorId > 0) objLead.InspectorName = id.InspectorId; else { InspectorMaster inspector = AddInspector(objLead, table.Rows[i]["Inspector Name"].ToString()); objLead.InspectorName = inspector.InspectorId; } } if (table.Rows[i]["Inspector Cell"] != string.Empty) { str = table.Rows[i]["Inspector Cell"].ToString(); if (str.Length > 20) str = objLead.InspectorCell = table.Rows[i]["Inspector Cell"].ToString().Substring(0, 20); else objLead.InspectorCell = table.Rows[i]["Inspector Cell"].ToString(); } if (table.Rows[i]["Inspector Email"] != string.Empty) { str = table.Rows[i]["Inspector Email"].ToString(); ; if (str.Length > 100) objLead.InspectorEmail = table.Rows[i]["Inspector Email"].ToString().Substring(0, 100); else objLead.InspectorEmail = table.Rows[i]["Inspector Email"].ToString(); } if (table.Rows[i]["Phone Number"] != string.Empty) { str = table.Rows[i]["Phone Number"].ToString(); if (str.Length > 20) objLead.PhoneNumber = table.Rows[i]["Phone Number"].ToString().Substring(0, 20); else objLead.PhoneNumber = table.Rows[i]["Phone Number"].ToString(); } if (table.Rows[i]["Secondary Phone"] != string.Empty) { str = table.Rows[i]["Secondary Phone"].ToString(); if (str.Length > 20) objLead.SecondaryPhone = str.Substring(0, 20); else objLead.SecondaryPhone = str; } //if (table.Rows[i]["Webform Source"] != string.Empty) { // //objLead.WebformSource = table.Rows[i]["Webform Source"].ToString(); // var id = WebFormSourceManager.GetByName(table.Rows[i]["Webform Source"].ToString()); // if (id != null && id.WebformSourceId > 0) // objLead.WebformSource = id.WebformSourceId; //} if (!string.IsNullOrEmpty(table.Rows[i]["Type of Damage"].ToString())) { //objLead.TypeOfDamage = table.Rows[i]["Type of Damage"].ToString(); var id = TypeofDamageManager.getbyTypeOfDamage(table.Rows[i]["Type of Damage"].ToString()); objLead.TypeOfDamage = id.TypeOfDamage; //string dmgid = string.Empty; //string[] dmg = table.Rows[i]["Type of Damage"].ToString().Split(','); //for (int d = 0; d < dmg.Length; d++) { // string dmgtext = dmg[d]; // var dmgdata = TypeofDamageManager.getbyTypeOfDamage(dmgtext); // if (dmgdata != null && dmgdata.TypeOfDamage != null && dmgdata.TypeOfDamage.ToString() != string.Empty) { // dmgid += dmgdata.TypeOfDamageId + ","; // } // else { // TypeOfDamageMaster objdmg = new TypeOfDamageMaster(); // objdmg.TypeOfDamage = dmgtext.Length > 100 ? dmgtext.Substring(0, 100) : dmgtext; // objdmg.Status = true; // TypeOfDamageMaster sv = TypeofDamageManager.Save(objdmg); // dmgid += sv.TypeOfDamageId + ","; // } //} //objLead.TypeOfDamage = dmgid; str = table.Rows[i]["Type of Damage"].ToString(); if (str.Length > 250) objLead.TypeofDamageText = table.Rows[i]["Type of Damage"].ToString().Substring(0, 250); else objLead.TypeofDamageText = table.Rows[i]["Type of Damage"].ToString(); //string Damagetxt = string.Empty; //string DamageId = string.Empty; //for (int j = 0; j < chkTypeOfDamage.Items.Count; j++) //{ // if (chkTypeOfDamage.Items[j].Selected == true) // { // Damagetxt += chkTypeOfDamage.Items[j].Text + ','; // DamageId += chkTypeOfDamage.Items[j].Value + ','; // } //} } if (!string.IsNullOrEmpty(table.Rows[i]["Type of Property"].ToString())) { var id = PropertyTypeManager.GetByPropertyName(table.Rows[i]["Type of Property"].ToString()); if (id != null && id.TypeOfPropertyId > 0) { objLead.TypeOfProperty = id.TypeOfPropertyId; if (id.TypeOfProperty.Contains("Home")) policyType = 1; if (id.TypeOfProperty.Contains("Commercial")) policyType = 2; if (id.TypeOfProperty.Contains("Flood")) policyType = 3; if (id.TypeOfProperty.Contains("Earthquake")) policyType = 4; } } if (table.Rows[i]["Market Value"] != string.Empty) { decimal MarketValue = 0; decimal.TryParse(table.Rows[i]["Market Value"].ToString(), out MarketValue); objLead.MarketValue = MarketValue; //Convert.ToDecimal(table.Rows[i]["Market Value"]); } if (table.Rows[i]["Loss Address"] != string.Empty) { str = table.Rows[i]["Loss Address"].ToString(); if (str.Length > 100) objLead.LossAddress = str.Substring(0, 100); else objLead.LossAddress = str; } if (table.Rows[i]["City"] != string.Empty) objLead.CityName = table.Rows[i]["City"].ToString(); if (table.Rows[i]["State"] != string.Empty) objLead.StateName = table.Rows[i]["State"].ToString(); if (table.Rows[i]["Zip"] != string.Empty) objLead.Zip = table.Rows[i]["Zip"].ToString(); if (table.Rows[i]["Property Damage Estimate"] != string.Empty) { decimal PropertyDamageEstimate = 0; decimal.TryParse(table.Rows[i]["Property Damage Estimate"].ToString(), out PropertyDamageEstimate); objLead.PropertyDamageEstimate = PropertyDamageEstimate;// Convert.ToDecimal(table.Rows[i]["Property Damage Estimate"]); } //if (table.Rows[i]["Habitable"] != string.Empty) { // //objLead.Habitable = table.Rows[i]["Habitable"].ToString(); // var id = HabitableManager.GetbyHabitable(table.Rows[i]["Habitable"].ToString()); // if (id != null && id.HabitableId > 0) // objLead.Habitable = id.HabitableId; //} //if (table.Rows[i]["Wind Policy"] != string.Empty) { // //objLead.WindPolicy = table.Rows[i]["Wind Policy"].ToString(); // //var id = WindPolicyManager.getbyWindPolicy(table.Rows[i]["Habitable"].ToString()); // var id = WindPolicyManager.getbyWindPolicy(table.Rows[i]["Wind Policy"].ToString()); // if (id != null && id.WindPolicyId > 0) // objLead.WindPolicy = id.WindPolicyId; //} //if (table.Rows[i]["Flood Policy"] != string.Empty) { // //objLead.FloodPolicy = table.Rows[i]["Flood Policy"].ToString(); // var id = FloodPolicyManager.GetByFloodPolicy(table.Rows[i]["Flood Policy"].ToString()); // if (id != null && id.FloodPolicyId > 0) // objLead.FloodPolicy = id.FloodPolicyId; //} if (table.Rows[i]["Owner First Name"] != string.Empty) if (table.Rows[i]["Owner First Name"].ToString().Length > 50) objLead.OwnerFirstName = table.Rows[i]["Owner First Name"].ToString().Substring(0, 50); else objLead.OwnerFirstName = table.Rows[i]["Owner First Name"].ToString(); if (table.Rows[i]["Owner Last Name"] != string.Empty) { str = table.Rows[i]["Owner Last Name"].ToString(); objLead.OwnerLastName = str.Length > 50 ? str.Substring(0, 50) : str; } if (table.Rows[i]["Owner Phone Number"] != string.Empty) { str = table.Rows[i]["Owner Phone Number"].ToString(); objLead.OwnerPhone = str.Length > 15 ? str.Substring(0, 15) : str; } if (table.Rows[i]["Last Contact Date"] != string.Empty) objLead.LastContactDate = Convert.ToDateTime(table.Rows[i]["Last Contact Date"].ToString()); if (table.Rows[i]["Personal Referral"] != string.Empty) { str = table.Rows[i]["Personal Referral"].ToString(); objLead.HearAboutUsDetail = str.Length > 250 ? str.Substring(0, 250) : str; } StatusMaster statusMaster = null; if (table.Rows[i]["Status"] != string.Empty) { string statusName = table.Rows[i]["Status"].ToString(); statusName = statusName.Length > 100 ? statusName.Substring(0, 100) : statusName; statusMaster = StatusManager.GetByStatusName(statusName); if (statusMaster.StatusId == 0) { statusMaster = new StatusMaster(); statusMaster.clientID = clientID; statusMaster.InsertBy = objLead.UserId; statusMaster.InsertDate = DateTime.Now; statusMaster.isCountable = true; statusMaster.isCountAsOpen = true; statusMaster.Status = true; statusMaster.StatusName = statusName; statusMaster = StatusManager.Save(statusMaster); } } objLead.Status = 1; objLead.InsertBy = objLead.UserId; // 2013-08-29 tortega if (clientID > 0) objLead.ClientID = clientID; Leads newLead = LeadsManager.Save(objLead); if (newLead != null) { LeadComment objLeadComment = null; // add policy CRM.Data.Entities.LeadPolicy policy = new CRM.Data.Entities.LeadPolicy(); policy.PolicyType = 1; policy.LeadId = newLead.LeadId; policy.IsActive = true; policy.isAllDocumentUploaded = false; if (statusMaster != null) policy.LeadStatus = statusMaster.StatusId; if (adjusterID > 0) policy.AdjusterID = adjusterID; if (table.Rows[i]["Claims Number"] != string.Empty) policy.ClaimNumber = table.Rows[i]["Claims Number"].ToString(); if (table.Rows[i]["Site Survey Date"] != string.Empty) policy.SiteSurveyDate = Convert.ToDateTime(table.Rows[i]["Site Survey Date"].ToString()); LeadPolicyManager.Save(policy); if (!string.IsNullOrEmpty(table.Rows[i]["Reported to Insurer"].ToString())) { objLeadComment = new LeadComment(); int LeadID = objLead.LeadId; objLeadComment.LeadId = LeadID; objLeadComment.UserId = objLead.UserId; objLeadComment.Status = 1; // 2013-08-29 tortega objLeadComment.PolicyType = policyType; str = table.Rows[i]["Reported to Insurer"].ToString(); if (str.Length > 8000) objLeadComment.CommentText = "Reported to Insurer " + str.Substring(0, 8000); else objLeadComment.CommentText = "Reported to Insurer " + str; LeadComment objld = LeadCommentManager.Save(objLeadComment); } if (!string.IsNullOrEmpty(table.Rows[i]["Claimant Comments"].ToString())) { objLeadComment = new LeadComment(); int LeadID = objLead.LeadId; objLeadComment.LeadId = LeadID; objLeadComment.UserId = objLead.UserId; objLeadComment.Status = 1; // 2013-08-29 tortega objLeadComment.PolicyType = policyType; str = table.Rows[i]["Claimant Comments"].ToString(); if (str.Length > 8000) objLeadComment.CommentText = str.Substring(0, 8000); else objLeadComment.CommentText = str; LeadComment objld = LeadCommentManager.Save(objLeadComment); } } } //for (int i = 0; i < table.Rows.Count; i++) { scope.Complete(); } string rootFolderPath = Server.MapPath("~//CSVLoad//"); string filesToDelete = FileUpload1.FileName; string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete); foreach (string file in fileList) { System.IO.File.Delete(file); } lblSave.Text = "Data Saved Successfully !!!"; lblSave.Visible = true; } } } catch (Exception ex) { lblError.Text = "There Is a problem in data save !!!"; lblError.Visible = true; Core.EmailHelper.emailError(ex); } }
protected void UploadTemplate2_bak() { // original format designed by Vivek lblSave.Text = string.Empty; lblSave.Visible = false; lblError.Text = string.Empty; lblError.Visible = false; lblMessage.Text = string.Empty; lblMessage.Visible = false; // 2013-02-09 tortega -- Added data validation prior to import. File is not aborted in the event of incorrect data. string str = null; int clientID = Core.SessionHelper.getClientId(); // assume homeowner int policyType = 1; DateTime DateSubmitted = DateTime.Now; try { if (FileUpload1.HasFile) { string ext = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName); string ActualFileName = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(@"\") + 1); string FileNameWithoutExt = ActualFileName.Replace(ext, ""); if (ext == ".csv") { if (!Directory.Exists(Server.MapPath("~//CSVLoad//"))) { Directory.CreateDirectory(Server.MapPath("~//CSVLoad//")); } FileUpload1.SaveAs(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName)); DataTable table = CSVReader.ReadCSVFile(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName), true); using (TransactionScope scope = new TransactionScope()) { Leads objLead = null; for (int i = 0; i < table.Rows.Count; i++) { objLead = new Leads(); //objLead.LeadStatus = 1; // active objLead.OriginalLeadDate = DateTime.Now; objLead.TypeOfProperty = 18; //residential objLead.UserId = Convert.ToInt32(Session["UserId"]); if (table.Rows[i]["Create Date"] != string.Empty) { DateTime.TryParse(table.Rows[i]["Create Date"].ToString(), out DateSubmitted); objLead.DateSubmitted = DateSubmitted; objLead.OriginalLeadDate = DateSubmitted; } if (table.Rows[i]["Last Name"] != string.Empty) { str = table.Rows[i]["Last Name"].ToString(); if (str.Length > 50) { objLead.ClaimantLastName = str.Substring(0, 50); objLead.OwnerLastName = objLead.ClaimantLastName; } else { objLead.ClaimantLastName = str; objLead.OwnerLastName = str; } } if (table.Rows[i]["First Name"] != string.Empty) { str = table.Rows[i]["First Name"].ToString(); if (str.Length > 50) { objLead.ClaimantFirstName = str.Substring(0, 50); objLead.OwnerFirstName = objLead.ClaimantFirstName; } else { objLead.ClaimantFirstName = str; objLead.OwnerFirstName = str; } } if (table.Rows[i]["Middle Name"] != string.Empty) { str = table.Rows[i]["Middle Name"].ToString(); if (str.Length > 50) { objLead.ClaimantMiddleName = str.Substring(0, 50); } else { objLead.ClaimantMiddleName = str; } } if (table.Rows[i]["E-mail"] != string.Empty) { str = table.Rows[i]["E-mail"].ToString(); if (str.Length > 100) objLead.EmailAddress = str.Substring(0, 100); else objLead.EmailAddress = str; } if (table.Rows[i]["Personal E-mail"] != string.Empty) { str = table.Rows[i]["Personal E-mail"].ToString(); if (str.Length > 100) objLead.SecondaryEmail = str.Substring(0, 100); else objLead.SecondaryEmail = str; } if (table.Rows[i]["Mobile Phone"] != string.Empty) { str = table.Rows[i]["Mobile Phone"].ToString(); if (str.Length > 20) objLead.SecondaryPhone = str.Substring(0, 20); else objLead.SecondaryPhone = str; } if (table.Rows[i]["Salutation"] != string.Empty) { str = table.Rows[i]["Salutation"].ToString(); if (str.Length > 50) objLead.Salutation = str.Substring(0, 20); else objLead.Salutation = str; } string adjusterName = null; int? adjusterID = null; AdjusterMaster adjuster = null; if (table.Rows[i]["Adjuster Name"] != string.Empty) adjusterName = table.Rows[i]["Adjuster Name"].ToString(); string adjusterEmail = null; string adjusterFax = null; string AdjusterPhone = null; string AdjusterCo = null; string AdjusterAddress = null; if (table.Rows[i]["Adjuster Email"] != string.Empty) adjusterEmail = table.Rows[i]["Adjuster Email"].ToString(); if (table.Rows[i]["Adjuster Fax"] != string.Empty) adjusterFax = table.Rows[i]["Adjuster Fax"].ToString(); if (table.Rows[i]["Adjuster Phone"] != string.Empty) AdjusterPhone = table.Rows[i]["Adjuster Phone"].ToString(); if (table.Rows[i]["Adjuster Co"] != string.Empty) AdjusterCo = table.Rows[i]["Adjuster Co"].ToString(); if (table.Rows[i]["Adj Address"] != string.Empty) AdjusterAddress = table.Rows[i]["Adj Address"].ToString(); if (!string.IsNullOrEmpty(adjusterName)) { adjuster = AdjusterManager.GetByAdjusterName(adjusterName.Trim()); if (adjuster.AdjusterId == 0) { // add adjuster adjuster = new AdjusterMaster(); adjuster.Status = true; adjuster.AdjusterName = adjusterName.Trim(); adjuster.ClientId = clientID; adjuster.InsertBy = objLead.UserId; adjuster.InsertDate = DateTime.Now; adjuster.isEmailNotification = true; adjuster.email = adjusterEmail; adjuster.Address1 = AdjusterAddress; adjuster.PhoneNumber = AdjusterPhone; adjuster.FaxNumber = adjusterFax; adjuster.CompanyName = AdjusterCo; adjuster = AdjusterManager.Save(adjuster); } adjusterID = adjuster.AdjusterId; } if (table.Rows[i]["Date of Loss"] != string.Empty) { DateTime lossDate = DateTime.MinValue; if (DateTime.TryParse(table.Rows[i]["Date of Loss"].ToString(), out lossDate)) objLead.LossDate = lossDate; } if (table.Rows[i]["Loss Location"] != string.Empty) objLead.LossLocation = table.Rows[i]["Loss Location"].ToString(); if (table.Rows[i]["Address 1"] != string.Empty) objLead.LossAddress = table.Rows[i]["Address 1"].ToString(); if (table.Rows[i]["Address 2"] != string.Empty) objLead.LossAddress2 = table.Rows[i]["Address 2"].ToString(); if (table.Rows[i]["City"] != string.Empty) objLead.CityName = table.Rows[i]["City"].ToString(); if (table.Rows[i]["State"] != string.Empty) objLead.StateName = table.Rows[i]["State"].ToString(); if (table.Rows[i]["ZIP Code"] != string.Empty) objLead.Zip = table.Rows[i]["ZIP Code"].ToString(); if (table.Rows[i]["Company"] != string.Empty) objLead.BusinessName = table.Rows[i]["Company"].ToString(); if (table.Rows[i]["Adjuster Name"] != string.Empty) adjusterName = table.Rows[i]["Adjuster Name"].ToString(); if (table.Rows[i]["Phone"] != string.Empty) { str = table.Rows[i]["Phone"].ToString(); if (str.Length > 20) objLead.PhoneNumber = str.Substring(0, 20); else objLead.PhoneNumber = str.ToString(); } StatusMaster statusMaster = null; string statusName = null; if (table.Rows[i]["File Status"] != string.Empty) { statusName = table.Rows[i]["File Status"].ToString(); statusMaster = StatusManager.GetByStatusName(statusName); if (statusMaster.StatusId == 0) { statusMaster = new StatusMaster(); statusMaster.clientID = clientID; statusMaster.InsertBy = objLead.UserId; statusMaster.InsertDate = DateTime.Now; statusMaster.isCountable = true; statusMaster.Status = true; statusMaster.StatusName = statusName; statusMaster = StatusManager.Save(statusMaster); } } if (!string.IsNullOrEmpty(table.Rows[i]["Peril"].ToString())) { var id = TypeofDamageManager.getbyTypeOfDamage(table.Rows[i]["Peril"].ToString()); objLead.TypeOfDamage = id.TypeOfDamage; //string dmgid = string.Empty; //string[] dmg = table.Rows[i]["Type of Damage"].ToString().Split(','); //for (int d = 0; d < dmg.Length; d++) { // string dmgtext = dmg[d]; // var dmgdata = TypeofDamageManager.getbyTypeOfDamage(dmgtext); // if (dmgdata != null && dmgdata.TypeOfDamage != null && dmgdata.TypeOfDamage.ToString() != string.Empty) { // dmgid += dmgdata.TypeOfDamageId + ","; // } // else { // TypeOfDamageMaster objdmg = new TypeOfDamageMaster(); // objdmg.TypeOfDamage = dmgtext.Length > 100 ? dmgtext.Substring(0, 100) : dmgtext; // objdmg.Status = true; // TypeOfDamageMaster sv = TypeofDamageManager.Save(objdmg); // dmgid += sv.TypeOfDamageId + ","; // } //} //objLead.TypeOfDamage = dmgid; str = table.Rows[i]["Peril"].ToString(); if (str.Length > 250) objLead.TypeofDamageText = str.Substring(0, 250).Replace("/", ","); else objLead.TypeofDamageText = str.Replace("/", ","); } objLead.Status = 1; // 2013-08-29 tortega if (clientID > 0) objLead.ClientID = clientID; Leads newLead = LeadsManager.Save(objLead); if (newLead != null) { if (table.Rows[i]["Certified Mail Number"] != string.Empty) AddComments(newLead.LeadId, "Certified Mail Number: " + table.Rows[i]["Certified Mail Number"].ToString()); //if (table.Rows[i]["Contract Signed Date"] != string.Empty) // AddComments(newLead.LeadId, "Contract Signed Date: " + table.Rows[i]["Contract Signed Date"].ToString()); if (table.Rows[i]["Last E-mail"] != string.Empty) AddComments(newLead.LeadId, "Last E-mail Date: " + table.Rows[i]["Last E-mail"].ToString()); if (table.Rows[i]["Last Meeting"] != string.Empty) AddComments(newLead.LeadId, "Last Meeting Date: " + table.Rows[i]["Last Meeting"].ToString()); if (table.Rows[i]["Letter Date"] != string.Empty) AddComments(newLead.LeadId, "Letter Date: " + table.Rows[i]["Letter Date"].ToString()); // add policy CRM.Data.Entities.LeadPolicy policy = new CRM.Data.Entities.LeadPolicy(); policy.PolicyType = 1; policy.LeadId = newLead.LeadId; policy.IsActive = true; policy.isAllDocumentUploaded = false; if (adjusterID != null) policy.AdjusterID = adjusterID; if (table.Rows[i]["Claim Number"] != string.Empty) policy.ClaimNumber = table.Rows[i]["Claim Number"].ToString(); if (table.Rows[i]["Policy Number"] != string.Empty) policy.PolicyNumber = table.Rows[i]["Policy Number"].ToString(); if (table.Rows[i]["Policy Period"] != string.Empty) policy.PolicyPeriod = table.Rows[i]["Policy Period"].ToString(); if (table.Rows[i]["File Number"] != string.Empty) policy.InsurerFileNo = table.Rows[i]["File Number"].ToString(); if (statusMaster != null) policy.LeadStatus = statusMaster.StatusId; if (table.Rows[i]["Ins Carrier"] != string.Empty) policy.InsuranceCompanyName = table.Rows[i]["Ins Carrier"].ToString(); if (table.Rows[i]["Ins Co Address"] != string.Empty) policy.InsuranceAddress = table.Rows[i]["Ins Co Address"].ToString(); if (table.Rows[i]["Ins Co City"] != string.Empty) { string cityName = table.Rows[i]["Ins Co City"].ToString(); CityMaster cityMaster = City.GetByCityName(cityName); if (cityMaster != null && cityMaster.CityId > 0) policy.InsuranceCity = cityMaster.CityId; } if (table.Rows[i]["Ins Co State"] != string.Empty) { string stateName = table.Rows[i]["Ins Co State"].ToString(); StateMaster stateMaster = State.Getstateid(stateName); if (stateMaster != null && stateMaster.StateId > 0) policy.InsuranceState = stateMaster.StateId; } if (table.Rows[i]["Ins Co Zip"] != string.Empty) { string zipCode = table.Rows[i]["Ins Co Zip"].ToString(); ZipCodeMaster zipMaster = ZipCode.GetByZipCode(zipCode); if (zipMaster != null && zipMaster.ZipCodeID > 0) policy.InsuranceZipCode = zipMaster.ZipCodeID.ToString(); } LeadPolicyManager.Save(policy); } } //for (int i = 0; i < table.Rows.Count; i++) { scope.Complete(); } string rootFolderPath = Server.MapPath("~//CSVLoad//"); string filesToDelete = FileUpload1.FileName; string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete); foreach (string file in fileList) { System.IO.File.Delete(file); } lblSave.Text = "Data Saved Successfully !!!"; lblSave.Visible = true; } } } catch (Exception ex) { lblError.Text = "There Is a problem in data save !!!"; lblError.Visible = true; Core.EmailHelper.emailError(ex); } }
private Claim createClaim(int policyID, DataRow dataRow) { decimal amount = 0; AdjusterMaster adjuster = null; string adjusterName = null; string causeofLoss = null; Claim claim = null; string claimstatus = null; int clientID = SessionHelper.getClientId(); Contact contact = null; DateTime dateTime = DateTime.MinValue; LeadContactType contactType = null; string ownerManagerName = null; string ownerManagerEntityName = null; int severity = 0; string supervisorName = null; string teamLead = null; TypeOfDamageMaster damageType = null; int userID = SessionHelper.getUserId(); string userFieldName = null; claim = new Claim(); claim.PolicyID = policyID; claim.IsActive = true; // Insurer Claim ID userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Insurer Claim ID"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { claim.InsurerClaimNumber = dataRow[userFieldName].ToString().Trim(); claim.AdjusterClaimNumber = claim.InsurerClaimNumber; } // Adjuster Claim Number userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Adjuster Claim Number"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { claim.AdjusterClaimNumber = dataRow[userFieldName].ToString().Trim(); } // Claim Status userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Claim Status"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { claimstatus = dataRow[userFieldName].ToString().Trim(); if (!string.IsNullOrEmpty(claimstatus)) { StatusMaster statusMaster = StatusManager.GetByStatusName(clientID, claimstatus); if (statusMaster.StatusId == 0) { statusMaster.StatusName = claimstatus; statusMaster.clientID = clientID; statusMaster.Status = true; statusMaster = StatusManager.Save(statusMaster); } claim.StatusID = statusMaster.StatusId; } } #region Dates // Date of Loss userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date of Loss"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.LossDate = dateTime; } } // Date Reported userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Reported"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateOpenedReported = dateTime; } } // Date First Closed userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date First Closed"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateFirstClosed = dateTime; } } // Date First Reopen userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date First Reopen"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateFirstReOpened = dateTime; } } // Date Assigned userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Assigned"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateAssigned = dateTime; } } // Date Acknowledged userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Acknowledged"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateAcknowledged = dateTime; } } // Date First Contact Attempted userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date First Contact Attempted"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateFirstContactAttempt = dateTime; } } //Date Contacted userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Contacted"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateContacted = dateTime; } } //Date Inspection Scheduled userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Inspection Scheduled"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateInspectionScheduled = dateTime; } } // Date Inspection Completed userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Inspection Completed"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateInspectionCompleted = dateTime; } } // Date Estimate Uploaded userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Estimate Uploaded"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateEstimateUploaded = dateTime; } } // Date of Initial Reserve Change userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date of Initial Reserve Change"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateInitialReserveChange = dateTime; } } // Date Indemnity Payment Requested userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Indemnity Payment Requested"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateIndemnityPaymentRequested = dateTime; } } // Date Indemnity Payment Approved userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Indemnity Payment Approved"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateIndemnityPaymentApproved = dateTime; } } // Date Indemnity Payment Issued userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Indemnity Payment Issued"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateIndemnityPaymentIssued = dateTime; } } // Date Completed userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Completed"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateCompleted = dateTime; } } // Date Closed userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Closed"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateClosed = dateTime; } } // Date Closed userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Date Closed"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (DateTime.TryParse(dataRow[userFieldName].ToString(), out dateTime)) { claim.DateClosed = dateTime; } } #endregion userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Cycle Time"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (decimal.TryParse(dataRow[userFieldName].ToString(), out amount)) { claim.CycleTime = amount; } } userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "ReOpenCycle Time"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (decimal.TryParse(dataRow[userFieldName].ToString(), out amount)) { claim.ReopenCycleTime = amount; } } #region adjuster userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Adjuster Name"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { adjusterName = dataRow[userFieldName].ToString().Trim(); adjuster = AdjusterManager.GetByAdjusterName(clientID, adjusterName); if (adjuster.AdjusterId == 0) { // add adjuster adjuster = new AdjusterMaster(); adjuster.Status = true; adjuster.AdjusterName = adjusterName.Trim(); adjuster.ClientId = clientID; adjuster.InsertBy = userID; adjuster.InsertDate = DateTime.Now; adjuster.isEmailNotification = true; adjuster = AdjusterManager.Save(adjuster); } claim.AdjusterID = adjuster.AdjusterId; } #endregion #region supervisor userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Supervisor Name"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { supervisorName = dataRow[userFieldName].ToString().Trim(); if (!string.IsNullOrEmpty(supervisorName)) { contactType = LeadContactTypeManager.Get(clientID, "Supervisor"); if (contactType == null) { contactType = addNewContactType(clientID, "Supervisor"); } contact = ContactManager.Get(clientID, supervisorName); if (contact == null) { contact = addNewContact(clientID, supervisorName, contactType.ID); } claim.SupervisorID = contact.ContactID; } } #endregion #region Team Lead userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Team Lead Name"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { teamLead = dataRow[userFieldName].ToString().Trim(); if (!string.IsNullOrEmpty(teamLead)) { contactType = LeadContactTypeManager.Get(clientID, "Team Lead"); if (contactType == null) { contactType = addNewContactType(clientID, "Team Lead"); } contact = ContactManager.Get(clientID, teamLead); if (contact == null) { contact = addNewContact(clientID, teamLead, contactType.ID); } claim.TeamLeadID = contact.ContactID; } } #endregion #region Owner Manager Name userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Owner Manager Name"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { ownerManagerName = dataRow[userFieldName].ToString().Trim(); if (!string.IsNullOrEmpty(ownerManagerName)) { contactType = LeadContactTypeManager.Get(clientID, "Owner Manager"); if (contactType == null) { contactType = addNewContactType(clientID, "Owner Manager"); } contact = ContactManager.Get(clientID, ownerManagerName); if (contact == null) { contact = addNewContact(clientID, ownerManagerName, contactType.ID); } claim.ManagerID = contact.ContactID; } } #endregion #region Owner Manager Entity Name userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Owner Manager Entity Name"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { ownerManagerEntityName = dataRow[userFieldName].ToString().Trim(); if (!string.IsNullOrEmpty(ownerManagerEntityName)) { contactType = LeadContactTypeManager.Get(clientID, "Owner Manager Entity Name"); if (contactType == null) { contactType = addNewContactType(clientID, "Owner Manager Entity Name"); } contact = ContactManager.Get(clientID, ownerManagerEntityName); if (contact == null) { contact = addNewContact(clientID, ownerManagerEntityName, contactType.ID); } claim.ManagerEntityID = contact.ContactID; } } #endregion // severity userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Severity"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { if (int.TryParse(dataRow[userFieldName].ToString().Trim(), out severity)) { claim.SeverityNumber = severity; } } // event userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Event Type"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { claim.EventType = dataRow[userFieldName].ToString().Trim(); } // event name userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Event Name"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { claim.EventName = dataRow[userFieldName].ToString().Trim(); } // Cause of Loss Description userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Cause of Loss Description"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { causeofLoss = dataRow[userFieldName].ToString().Trim(); damageType = TypeofDamageManager.GetTypeOfDamage(clientID, causeofLoss); if (damageType.TypeOfDamageId == 0) { damageType.ClientId = clientID; damageType.Status = true; damageType.TypeOfDamage = causeofLoss; damageType = TypeofDamageManager.Save(damageType); } claim.CauseOfLoss = damageType.TypeOfDamageId.ToString(); } #region Amounts // Claim Workflow Type userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Claim Workflow Type"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { claim.ClaimWorkflowType = dataRow[userFieldName].ToString().Trim(); } // Outstanding Indemnity Reserve userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Outstanding Indemnity Reserve"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount); claim.OutstandingIndemnityReserve = amount; } // Outstanding LAE Reserves userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Outstanding LAE Reserves"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount); claim.OutstandingLAEReserves = amount; } // Total Indemnity Paid userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Total Indemnity Paid"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount); claim.TotalIndemnityPaid = amount; } // Coverage A Paid userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Coverage A Paid"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount); claim.CoverageAPaid = amount; } // Coverage B Paid userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Coverage B Paid"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount); claim.CoverageBPaid = amount; } // Coverage C Paid userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Coverage C Paid"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount); claim.CoverageCPaid = amount; } // Coverage D Paid userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Coverage D Paid"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount); claim.CoverageDPaid = amount; } // Total Expenses Paid userFieldName = Core.CSVHelper.getUserFieldName(this.mappedFields, "Total Expenses Paid"); if (!string.IsNullOrEmpty(userFieldName) && dataRow[userFieldName] != null) { decimal.TryParse(dataRow[userFieldName].ToString().Trim(), out amount); claim.TotalExpensesPaid = amount; } #endregion claim = ClaimsManager.Save(claim); return(claim); }
private void copyMasterStatus(int sourceClientID, int targetClientID, int clientUserID) { List<StatusMaster> statuses = null; // get list of status from model statuses = StatusManager.GetAll(sourceClientID); foreach (StatusMaster status in statuses) { StatusMaster newStatusMaster = new StatusMaster(); newStatusMaster.clientID = targetClientID; newStatusMaster.InsertBy = clientUserID; newStatusMaster.InsertDate = DateTime.Now; newStatusMaster.isCountable = status.isCountable; newStatusMaster.Status = status.Status; newStatusMaster.StatusName = status.StatusName; newStatusMaster.UpdateBy = clientUserID; newStatusMaster.UpdateDate = DateTime.Now; newStatusMaster.isCountAsOpen = status.isCountAsOpen; StatusManager.Save(newStatusMaster); } }
private void setReminder(int leadID, CRM.Data.Entities.LeadPolicy policy, int masterStatusID) { int lastStatusID = 0; double duration = 0; LeadTask task = null; DateTime reminderDate = DateTime.MaxValue; string sdate = null; // return if no change in status int.TryParse(hf_lastStatusID.Value, out lastStatusID); if (lastStatusID == masterStatusID) { return; } // get status with reminder duration StatusMaster statusMaster = StatusManager.GetStatusId(masterStatusID); // return if master status not loaded properly if (statusMaster == null) { return; } // get task associated with policy task = TasksManager.GetPolicyReminderTask(leadID, policy.Id); // master status has no reminder if (statusMaster.ReminderMaster == null) { // delete existing reminder if (task != null) { TasksManager.Delete(task.id); } } else { if (task == null) { // create new reminder as task task = new LeadTask(); task.lead_id = leadID; task.lead_policy_id = policy.Id; task.policy_type = policy.PolicyType; } if (SessionHelper.getClientId() > 0) { task.creator_id = SessionHelper.getClientId(); } // update existing reminder task.master_status_id = masterStatusID; sdate = DateTime.Now.ToShortDateString() + " 5:00:00 AM"; DateTime.TryParse(sdate, out reminderDate); // get duration from status reminder if (statusMaster.ReminderMaster != null) { duration = (double)(statusMaster.ReminderMaster.Duration ?? 0); } if ((int)statusMaster.ReminderMaster.DurationType == 1) { task.start_date = reminderDate.AddHours(duration); } else { task.start_date = reminderDate.AddDays(duration); } task.end_date = task.start_date; task.status_id = 1; task.text = "Alert"; task.isAllDay = true; task.details = statusMaster.StatusName; // +"<div>Ins. Co: " + policy.InsuranceCompanyName + "</div><div>Pol: " + policy.PolicyNumber + "</div>"; task.owner_id = SessionHelper.getUserId(); TasksManager.Save(task); } // refresh tasks on parent page if (statusChanged != null) { statusChanged(this, null); } }
protected void btnSave_Click(object sender, EventArgs e) { lblError.Text = string.Empty; lblError.Visible = false; lblSave.Text = string.Empty; lblSave.Visible = false; lblMessage.Visible = false; lblMessage.Text = string.Empty; bool exists = false; int clientID = Core.SessionHelper.getClientId(); try { using (TransactionScope scope = new TransactionScope()) { if (clientID > 0) { exists = StatusManager.IsExist(txtStatus.Text.Trim(), Convert.ToInt32(hdId.Value), clientID); } else { exists = StatusManager.IsExist(txtStatus.Text.Trim(), Convert.ToInt32(hdId.Value)); } if (exists) { lblMessage.Text = "Status already exists."; lblMessage.Visible = true; txtStatus.Focus(); return; } StatusMaster status = StatusManager.GetStatusId(Convert.ToInt32(hdId.Value)); status.StatusName = txtStatus.Text; status.Status = true; if (clientID > 0) { status.clientID = clientID; } if (Convert.ToInt32(ddlReminder.SelectedValue) > 0) { status.ReminderID = Convert.ToInt32(ddlReminder.SelectedValue); } else { status.ReminderID = null; } status.isCountable = cbxIsCountable.Checked; status.isCountAsOpen = cbxIsCountAsOpen.Checked; StatusManager.Save(status); lblSave.Text = hdId.Value == "0" ? "Record Saved Sucessfully." : "Record Updated Sucessfully."; lblSave.Visible = true; scope.Complete(); } } catch (Exception ex) { lblError.Visible = true; lblError.Text = "Record Not Saved !!!"; Core.EmailHelper.emailError(ex); } }
public void UpdateStatusMaster(StatusMaster _StatusMaster) { _StatusMasterService.Update(_StatusMaster); }
protected void UploadTemplate2() { // original format designed by Vivek lblSave.Text = string.Empty; lblSave.Visible = false; lblError.Text = string.Empty; lblError.Visible = false; lblMessage.Text = string.Empty; lblMessage.Visible = false; // 2013-02-09 tortega -- Added data validation prior to import. File is not aborted in the event of incorrect data. string str = null; int fileLineNumber = 0; int clientID = Core.SessionHelper.getClientId(); // assume homeowner int policyType = 1; DateTime DateSubmitted = DateTime.Now; DateTime ContractDate = DateTime.Now; string columnValue = null; Mortgagee mortgagee = null; StatusMaster statusMaster = null; string statusName = null; try { if (FileUpload1.HasFile) { string ext = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName); string ActualFileName = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(@"\") + 1); string FileNameWithoutExt = ActualFileName.Replace(ext, ""); if (ext == ".csv") { if (!Directory.Exists(Server.MapPath("~//CSVLoad//"))) { Directory.CreateDirectory(Server.MapPath("~//CSVLoad//")); } FileUpload1.SaveAs(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName)); DataTable table = CSVReader.ReadCSVFile(Server.MapPath("~//CSVLoad//" + FileUpload1.FileName), true); using (TransactionScope scope = new TransactionScope()) { Leads objLead = null; for (int i = 0; i < table.Rows.Count; i++) { fileLineNumber = i; objLead = new Leads(); //objLead.LeadStatus = 1; // active objLead.OriginalLeadDate = DateTime.Now; objLead.TypeOfProperty = 18; //residential objLead.UserId = Convert.ToInt32(Session["UserId"]); try { if (columnExists(table, "Create Date") && table.Rows[i]["Create Date"] != string.Empty) { DateTime.TryParse(table.Rows[i]["Create Date"].ToString(), out DateSubmitted); objLead.DateSubmitted = DateSubmitted; objLead.OriginalLeadDate = DateSubmitted; } if (columnExists(table, "Last Name") && table.Rows[i]["Last Name"] != string.Empty) { str = table.Rows[i]["Last Name"].ToString(); if (str.Length > 50) { objLead.ClaimantLastName = str.Substring(0, 50); objLead.OwnerLastName = objLead.ClaimantLastName; } else { objLead.ClaimantLastName = str; objLead.OwnerLastName = str; } } if (columnExists(table, "First Name") && table.Rows[i]["First Name"] != string.Empty) { str = table.Rows[i]["First Name"].ToString(); if (str.Length > 50) { objLead.ClaimantFirstName = str.Substring(0, 50); objLead.OwnerFirstName = objLead.ClaimantFirstName; } else { objLead.ClaimantFirstName = str; objLead.OwnerFirstName = str; } } if (columnExists(table, "Middle Name") && table.Rows[i]["Middle Name"] != string.Empty) { str = table.Rows[i]["Middle Name"].ToString(); if (str.Length > 50) { objLead.ClaimantMiddleName = str.Substring(0, 50); } else { objLead.ClaimantMiddleName = str; } } if (columnExists(table, "E-mail") && table.Rows[i]["E-mail"] != string.Empty) { str = table.Rows[i]["E-mail"].ToString(); if (str.Length > 100) objLead.EmailAddress = str.Substring(0, 100); else objLead.EmailAddress = str; } if (columnExists(table, "Personal E-mail") && table.Rows[i]["Personal E-mail"] != string.Empty) { str = table.Rows[i]["Personal E-mail"].ToString(); if (str.Length > 100) objLead.SecondaryEmail = str.Substring(0, 100); else objLead.SecondaryEmail = str; } if (columnExists(table, "Mobile Phone") && table.Rows[i]["Mobile Phone"] != string.Empty) { str = table.Rows[i]["Mobile Phone"].ToString(); if (str.Length > 20) objLead.SecondaryPhone = str.Substring(0, 20); else objLead.SecondaryPhone = str; } if (columnExists(table, "Salutation") && table.Rows[i]["Salutation"] != string.Empty) { str = table.Rows[i]["Salutation"].ToString(); if (str.Length > 50) objLead.Salutation = str.Substring(0, 20); else objLead.Salutation = str; } } catch (Exception ex) { lblError.Text = "There Is a problem in data save !!!"; lblError.Visible = true; Core.EmailHelper.emailError(ex); throw new Exception(ex.Message); } string adjusterName = null; int? adjusterID = null; AdjusterMaster adjuster = null; if (columnExists(table, "Adjuster Name") && table.Rows[i]["Adjuster Name"] != string.Empty) adjusterName = table.Rows[i]["Adjuster Name"].ToString(); string adjusterEmail = null; string adjusterFax = null; string AdjusterPhone = null; string AdjusterCo = null; string AdjusterAddress = null; if (columnExists(table, "Adjuster Email") && table.Rows[i]["Adjuster Email"] != string.Empty) adjusterEmail = table.Rows[i]["Adjuster Email"].ToString(); if (columnExists(table, "Adjuster Fax") && table.Rows[i]["Adjuster Fax"] != string.Empty) adjusterFax = table.Rows[i]["Adjuster Fax"].ToString(); if (columnExists(table, "Adjuster Phone") && table.Rows[i]["Adjuster Phone"] != string.Empty) AdjusterPhone = table.Rows[i]["Adjuster Phone"].ToString(); if (columnExists(table, "Adjuster Co") && table.Rows[i]["Adjuster Co"] != string.Empty) AdjusterCo = table.Rows[i]["Adjuster Co"].ToString(); if (columnExists(table, "Adj Address") && table.Rows[i]["Adj Address"] != string.Empty) AdjusterAddress = table.Rows[i]["Adj Address"].ToString(); if (!string.IsNullOrEmpty(adjusterName)) { adjuster = AdjusterManager.GetByAdjusterName(adjusterName.Trim()); if (adjuster.AdjusterId == 0) { // add adjuster adjuster = new AdjusterMaster(); adjuster.Status = true; adjuster.AdjusterName = adjusterName.Trim(); adjuster.ClientId = clientID; adjuster.InsertBy = objLead.UserId; adjuster.InsertDate = DateTime.Now; adjuster.isEmailNotification = true; adjuster.email = adjusterEmail; adjuster.Address1 = AdjusterAddress; adjuster.PhoneNumber = AdjusterPhone; adjuster.FaxNumber = adjusterFax; adjuster.CompanyName = AdjusterCo; adjuster = AdjusterManager.Save(adjuster); } adjusterID = adjuster.AdjusterId; } if (columnExists(table, "ExaminerName") && table.Rows[i]["ExaminerName"] != string.Empty) { InspectorMaster inspector = InspectorManager.GetByName(table.Rows[i]["ExaminerName"].ToString()); if (inspector.InspectorId > 0) { objLead.InspectorName = inspector.InspectorId; } } //if (columnExists(table, "Loss Location") && table.Rows[i]["Loss Location"] != string.Empty) // objLead.LossLocation = table.Rows[i]["Loss Location"].ToString(); //if (columnExists(table, "Date of Loss") && table.Rows[i]["Date of Loss"] != string.Empty) { // DateTime lossDate = DateTime.MinValue; // if (DateTime.TryParse(table.Rows[i]["Date of Loss"].ToString(), out lossDate)) // objLead.LossDate = lossDate; //} if (columnExists(table, "Contract Signed Date") && table.Rows[i]["Contract Signed Date"] != string.Empty) objLead.ContractDate = Convert.ToDateTime(table.Rows[i]["Contract Signed Date"].ToString()); if (columnExists(table, "Address 1") && table.Rows[i]["Address 1"] != string.Empty) { str = table.Rows[i]["Address 1"].ToString(); if (str.Length > 100) objLead.MailingAddress = str.Substring(0, 99); else objLead.LossAddress = str.ToString(); } try { if (columnExists(table, "City") && table.Rows[i]["City"] != string.Empty) objLead.MailingCity = table.Rows[i]["City"].ToString(); if (columnExists(table, "State") && table.Rows[i]["State"] != string.Empty) objLead.MailingState = table.Rows[i]["State"].ToString(); if (columnExists(table, "ZIP Code") && table.Rows[i]["ZIP Code"] != string.Empty) objLead.MailingZip = table.Rows[i]["ZIP Code"].ToString(); if (columnExists(table, "Business Name") && table.Rows[i]["Business Name"] != string.Empty) objLead.BusinessName = table.Rows[i]["Business Name"].ToString(); if (columnExists(table, "Adjuster Name") && table.Rows[i]["Adjuster Name"] != string.Empty) adjusterName = table.Rows[i]["Adjuster Name"].ToString(); if (columnExists(table, "Phone") && table.Rows[i]["Phone"] != string.Empty) { str = table.Rows[i]["Phone"].ToString(); if (str.Length > 20) objLead.PhoneNumber = str.Substring(0, 20); else objLead.PhoneNumber = str.ToString(); } if (columnExists(table, "Loss Address") && table.Rows[i]["Loss Address"] != string.Empty) { str = table.Rows[i]["Loss Address"].ToString(); if (str.Length > 100) objLead.LossAddress = str.Substring(0, 99); else objLead.LossAddress = str.ToString(); } if (columnExists(table, "Loss City") && table.Rows[i]["Loss City"] != string.Empty) objLead.CityName = table.Rows[i]["Loss City"].ToString(); if (columnExists(table, "Loss State") && table.Rows[i]["Loss State"] != string.Empty) objLead.StateName = table.Rows[i]["Loss State"].ToString(); if (columnExists(table, "Loss Zip Code") && table.Rows[i]["Loss Zip Code"] != string.Empty) { str = table.Rows[i]["Loss Zip Code"].ToString(); if (str.Length < 5) str = "0" + str; objLead.Zip = str; } if (columnExists(table, "Fax") && table.Rows[i]["Fax"] != string.Empty) { str = table.Rows[i]["Fax"].ToString(); if (str.Length > 20) objLead.SecondaryPhone = str.Substring(0, 20); else objLead.SecondaryPhone = str.ToString(); } if (columnExists(table, "File Status") && table.Rows[i]["File Status"] != string.Empty) { statusName = table.Rows[i]["File Status"].ToString(); statusMaster = StatusManager.GetByStatusName(statusName); if (statusMaster.StatusId == 0) { statusMaster = new StatusMaster(); statusMaster.clientID = clientID; statusMaster.InsertBy = objLead.UserId; statusMaster.InsertDate = DateTime.Now; statusMaster.isCountable = true; statusMaster.Status = true; statusMaster.StatusName = statusName; statusMaster = StatusManager.Save(statusMaster); } } } catch (Exception ex) { lblError.Text = "There Is a problem in data save !!!"; lblError.Visible = true; Core.EmailHelper.emailError(ex); throw new Exception(ex.Message); } if (columnExists(table, "Peril") && !string.IsNullOrEmpty(table.Rows[i]["Peril"].ToString())) { var id = TypeofDamageManager.getbyTypeOfDamage(table.Rows[i]["Peril"].ToString()); if (id.TypeOfDamageId > 0) objLead.TypeOfDamage = id.TypeOfDamageId.ToString() + ","; //string dmgid = string.Empty; //string[] dmg = table.Rows[i]["Type of Damage"].ToString().Split(','); //for (int d = 0; d < dmg.Length; d++) { // string dmgtext = dmg[d]; // var dmgdata = TypeofDamageManager.getbyTypeOfDamage(dmgtext); // if (dmgdata != null && dmgdata.TypeOfDamage != null && dmgdata.TypeOfDamage.ToString() != string.Empty) { // dmgid += dmgdata.TypeOfDamageId + ","; // } // else { // TypeOfDamageMaster objdmg = new TypeOfDamageMaster(); // objdmg.TypeOfDamage = dmgtext.Length > 100 ? dmgtext.Substring(0, 100) : dmgtext; // objdmg.Status = true; // TypeOfDamageMaster sv = TypeofDamageManager.Save(objdmg); // dmgid += sv.TypeOfDamageId + ","; // } //} //objLead.TypeOfDamage = dmgid; str = table.Rows[i]["Peril"].ToString(); if (str.Length > 250) objLead.TypeofDamageText = str.Substring(0, 250).Replace("/", ","); else objLead.TypeofDamageText = str.Replace("/", ","); } objLead.Status = 1; // 2013-08-29 tortega if (clientID > 0) objLead.ClientID = clientID; Leads newLead = LeadsManager.Save(objLead); int policyTypeID = 1; if (newLead != null) { // add policy CRM.Data.Entities.LeadPolicy policy = new CRM.Data.Entities.LeadPolicy(); if (columnExists(table, "PolicyType") && table.Rows[i]["PolicyType"] != string.Empty) { policyTypeID = getPolicyType(table.Rows[i]["PolicyType"].ToString()); } policy.PolicyType = policyTypeID; policy.LeadId = newLead.LeadId; policy.IsActive = true; policy.isAllDocumentUploaded = false; if (adjusterID != null) policy.AdjusterID = adjusterID; if (columnExists(table, "LoanID") && table.Rows[i]["LoanID"] != string.Empty) { str = table.Rows[i]["LoanID"].ToString(); if (str.Length > 50) policy.LoanNumber = str.Substring(0, 50); else policy.LoanNumber = str; } if (columnExists(table, "DateOfEvaluation") && table.Rows[i]["DateOfEvaluation"] != string.Empty) { DateTime SiteSurveyDate = DateTime.MinValue; if (DateTime.TryParse(table.Rows[i]["DateOfEvaluation"].ToString(), out SiteSurveyDate)) policy.SiteSurveyDate = SiteSurveyDate; } if (columnExists(table, "Mortgagee") && table.Rows[i]["Mortgagee"] != string.Empty) { int id = getMortgageeID(table.Rows[i]["Mortgagee"].ToString(), clientID); if (id > 0) policy.MortgageeID = id; else { mortgagee = new Mortgagee(); mortgagee.ClientID = clientID; mortgagee.Status = true; mortgagee.MortageeName = table.Rows[i]["Mortgagee"].ToString(); mortgagee = MortgageeManager.Save(mortgagee); if (mortgagee.MortgageeID > 0) policy.MortgageeID = mortgagee.MortgageeID; } } if (columnExists(table, "Loss Location") && table.Rows[i]["Loss Location"] != string.Empty) policy.LossLocation = table.Rows[i]["Loss Location"].ToString(); if (columnExists(table, "Date of Loss") && table.Rows[i]["Date of Loss"] != string.Empty) { DateTime lossDate = DateTime.MinValue; if (DateTime.TryParse(table.Rows[i]["Date of Loss"].ToString(), out lossDate)) policy.LossDate = lossDate; } if (columnExists(table, "Policy Period") && table.Rows[i]["Policy Period"] != string.Empty) policy.PolicyPeriod = table.Rows[i]["Policy Period"].ToString(); string PolicyExpirationDate = null; if (columnExists(table, "PolicyExpirationDate") && table.Rows[i]["PolicyExpirationDate"] != string.Empty) PolicyExpirationDate = table.Rows[i]["PolicyExpirationDate"].ToString(); string effectiveDate = null; if (columnExists(table, "PolicyEffectiveDate") && table.Rows[i]["PolicyEffectiveDate"] != string.Empty) effectiveDate = table.Rows[i]["PolicyEffectiveDate"].ToString(); str = string.Format("{0} - {1}", effectiveDate ?? "N/A", PolicyExpirationDate ?? "N/A"); if (str.Length > 50) policy.PolicyPeriod = str.Substring(0, 50); else policy.PolicyPeriod = str; if (columnExists(table, "Claim Number") && table.Rows[i]["Claim Number"] != string.Empty) { str = table.Rows[i]["Claim Number"].ToString(); if (str.Length > 50) policy.ClaimNumber = str.Substring(0, 50); else policy.ClaimNumber = str; } if (columnExists(table, "Policy Number") && table.Rows[i]["Policy Number"] != string.Empty) { str = table.Rows[i]["Policy Number"].ToString(); if (str.Length > 100) policy.PolicyNumber = str.Substring(0, 100); else policy.PolicyNumber = str; } if (columnExists(table, "File Number") && table.Rows[i]["File Number"] != string.Empty) { str = table.Rows[i]["File Number"].ToString(); if (str.Length > 20) policy.InsurerFileNo = str.Substring(0, 20); else policy.InsurerFileNo = str; } if (statusMaster != null) policy.LeadStatus = statusMaster.StatusId; if (columnExists(table, "Ins Carrier") && table.Rows[i]["Ins Carrier"] != string.Empty) { str = table.Rows[i]["Ins Carrier"].ToString(); if (str.Length > 50) policy.InsuranceCompanyName = str.Substring(0, 50); else policy.InsuranceCompanyName = str; } if (columnExists(table, "Ins Co Address") && table.Rows[i]["Ins Co Address"] != string.Empty) { str = table.Rows[i]["Ins Co Address"].ToString(); if (str.Length > 50) policy.InsuranceAddress = str.Substring(0, 50); else policy.InsuranceAddress = str; } if (columnExists(table, "Ins Co City") && table.Rows[i]["Ins Co City"] != string.Empty) { string cityName = table.Rows[i]["Ins Co City"].ToString(); CityMaster cityMaster = City.GetByCityName(cityName); if (cityMaster != null && cityMaster.CityId > 0) policy.InsuranceCity = cityMaster.CityId; } if (columnExists(table, "Ins Co State") && table.Rows[i]["Ins Co State"] != string.Empty) { string stateName = table.Rows[i]["Ins Co State"].ToString(); StateMaster stateMaster = State.Getstateid(stateName); if (stateMaster != null && stateMaster.StateId > 0) policy.InsuranceState = stateMaster.StateId; } if (columnExists(table, "Ins Co Zip") && table.Rows[i]["Ins Co Zip"] != string.Empty) { string zipCode = table.Rows[i]["Ins Co Zip"].ToString(); ZipCodeMaster zipMaster = ZipCode.GetByZipCode(zipCode); if (zipMaster != null && zipMaster.ZipCodeID > 0) policy.InsuranceZipCode = zipMaster.ZipCodeID.ToString(); } LeadPolicyManager.Save(policy); // add policy comments if (columnExists(table, "Notes") && table.Rows[i]["Notes"] != string.Empty) { char[] splitTokens = { '\n' }; string[] lines = table.Rows[i]["Notes"].ToString().Split(splitTokens, StringSplitOptions.RemoveEmptyEntries); if (lines != null && lines.Length > 0) foreach (string line in lines) { string[] datetimeValues = line.Split(new char[] { ' ' }); if (datetimeValues.Length > 3) { string datetime = string.Format("{0} {1} {2}", datetimeValues[0] ?? "", datetimeValues[1] ?? "", datetimeValues[2] ?? ""); DateTime commentInsertDate = DateTime.Now; if (DateTime.TryParse(datetime, out commentInsertDate)) AddComments(newLead.LeadId, policyTypeID, line, commentInsertDate); else AddComments(newLead.LeadId, policyTypeID, line); } else AddComments(newLead.LeadId, policyTypeID, line); } //AddComments(newLead.LeadId, policyTypeID, table.Rows[i]["Notes"].ToString().Replace("\n","<br/>"); } if (columnExists(table, "Certified Mail Number") && table.Rows[i]["Certified Mail Number"] != string.Empty) AddComments(newLead.LeadId, policyTypeID, "Certified Mail Number: " + table.Rows[i]["Certified Mail Number"].ToString()); //if (columnExists(table, "Contract Signed Date") && table.Rows[i]["Contract Signed Date"] != string.Empty) // AddComments(newLead.LeadId, policyTypeID, "Contract Signed Date: " + table.Rows[i]["Contract Signed Date"].ToString()); if (columnExists(table, "Last E-mail") && table.Rows[i]["Last E-mail"] != string.Empty) AddComments(newLead.LeadId, policyTypeID, "Last E-mail Date: " + table.Rows[i]["Last E-mail"].ToString()); if (columnExists(table, "Last Meeting") && table.Rows[i]["Last Meeting"] != string.Empty) AddComments(newLead.LeadId, policyTypeID, "Last Meeting Date: " + table.Rows[i]["Last Meeting"].ToString()); if (columnExists(table, "Letter Date") && table.Rows[i]["Letter Date"] != string.Empty) AddComments(newLead.LeadId, policyTypeID, "Letter Date: " + table.Rows[i]["Letter Date"].ToString()); } } //for (int i = 0; i < table.Rows.Count; i++) { scope.Complete(); } string rootFolderPath = Server.MapPath("~//CSVLoad//"); string filesToDelete = FileUpload1.FileName; string[] fileList = System.IO.Directory.GetFiles(rootFolderPath, filesToDelete); foreach (string file in fileList) { System.IO.File.Delete(file); } lblSave.Text = "Data Saved Successfully !!!"; lblSave.Visible = true; } } } catch (Exception ex) { lblError.Text = "There Is a problem in data save !!!"; lblError.Visible = true; } }