Ejemplo n.º 1
0
        public RuleException TestRule(int clientID, Claim claim)
        {
            string claimLimit = null;
            bool isRuleMet = false;
            int numberOfClaims = 0;
            int numberOfClaimsLimit = 0;

            // skip if no adjuster assigned to claim
            if ((claim.AdjusterID ?? 0) == 0)
                return null;

            // get number of claims assigned to adjuster
            numberOfClaims = ClaimsManager.getAdjusterClaimCount((int)claim.AdjusterID);

            // get business rules for client/rule type id
            using (BusinessRuleManager repository = new BusinessRuleManager()) {
                rules = repository.GetBusinessRules(clientID, Globals.RuleType.AdjusterClaimReview);
            }

            if (rules != null && rules.Count > 0) {
                // build value array
                values = new string[] { claim.AdjusterID.ToString() };

                foreach (BusinessRule rule in rules) {
                    XElement ruleXML = XElement.Parse(rule.RuleXML);

                    XElement adjusterCondition = base.GetElement(ruleXML, "AdjusterID", claim.AdjusterID.ToString());

                    claimLimit = base.GetElementValue(ruleXML, "Claim");

                    if (adjusterCondition != null && !string.IsNullOrEmpty(claimLimit)) {
                        if (int.TryParse(claimLimit, out numberOfClaimsLimit) && numberOfClaimsLimit > 0) {

                            isRuleMet = (numberOfClaims <= numberOfClaimsLimit);
                        }
                    }

                    if (isRuleMet) {
                        // add exception to queue
                        ruleException = new RuleException();

                        ruleException.BusinessRuleID = rule.BusinessRuleID;

                        ruleException.ClientID = clientID;

                        ruleException.ObjectID = claim.ClaimID;

                        ruleException.ObjectTypeID = (int)Globals.ObjectType.Claim;

                        break;
                    }
                }
            }

            return this.ruleException;
        }
        public static void CheckSendMail(RuleException ruleExp)
        {
            if (ruleExp != null)
            {
                string adjusterEmail = string.Empty;
                string supervisorEmail = string.Empty;
                bool sendAdjuster = false;
                bool sendSupervisor = false;
                string recipient = string.Empty;
                int claimId = 0;

                BusinessRuleManager objRuleManager = new BusinessRuleManager();
                BusinessRule objRule = new BusinessRule();
                CRM.Data.Entities.Claim objClaim = new CRM.Data.Entities.Claim();
                CRM.Data.Entities.SecUser objSecUser = new Data.Entities.SecUser();
                AdjusterMaster adjustermaster = new AdjusterMaster();

                int businessRuleID = ruleExp.BusinessRuleID ?? 0;
                objRule = objRuleManager.GetBusinessRule(businessRuleID);
                if (objRule != null)
                {
                    claimId = ruleExp.ObjectID ?? 0;

                    objClaim = objRuleManager.GetClaim(claimId);
                    adjustermaster = objRuleManager.GetAdjuster(objClaim.AdjusterID ?? 0);
                    objSecUser = objRuleManager.GetSupervisor(objClaim.SupervisorID ?? 0);
                    if (objSecUser != null)
                    {
                        adjusterEmail = adjustermaster.email;
                        supervisorEmail = objSecUser.Email;

                        sendAdjuster = objRule.EmailAdjuster;
                        sendSupervisor = objRule.EmailSupervisor;

                        if (sendAdjuster == true && sendSupervisor == true)
                        {
                            recipient = adjusterEmail + "," + supervisorEmail;
                            notifyUser(objRule.Description, claimId, recipient);
                        }
                        else if (sendAdjuster == false && sendSupervisor == true)
                        {
                            recipient = supervisorEmail;
                            notifyUser(objRule.Description, claimId, recipient);
                        }
                        else if (sendAdjuster == true && sendSupervisor == false)
                        {

                            recipient = adjusterEmail;
                            notifyUser(objRule.Description, claimId, recipient);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected void gvBsuinessRules_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            BusinessRule businessRule = null;
            int businessRuleID = 0;

            lblMessage.Text = string.Empty;
            lblMessage.Visible = false;

            if (e.CommandName == "DoEdit")
            {
                businessRuleID = Convert.ToInt32(e.CommandArgument);
                using (BusinessRuleManager repository = new BusinessRuleManager())
                {
                    businessRule = repository.GetBusinessRule(businessRuleID);

                    if (businessRule != null)
                    {
                        editBusinessRule((int)businessRule.RuleID, businessRule.Rule.RuleName, businessRule);
                    }
                }
            }
            else if (e.CommandName == "DoDelete")
            {
                try
                {
                    businessRuleID = Convert.ToInt32(e.CommandArgument);

                    using (BusinessRuleManager repository = new BusinessRuleManager())
                    {
                        businessRule = repository.GetBusinessRule(businessRuleID);

                        businessRule.IsActive = false;

                        repository.Save(businessRule);

                        refreshBusinessRuleGrid();

                        lblMessage.Text = "Rule was deactivate successfully.";
                        lblMessage.CssClass = "ok";
                        lblMessage.Visible = true;
                        Login login = new Login();
                        login.formatException();
                        login.setRulexception();
                    }
                }
                catch (Exception ex)
                {
                    lblMessage.Text = "Rule was not deactivate.";
                    lblMessage.CssClass = "ok";
                    lblMessage.Visible = true;
                }
            }
        }
        public RuleException TestRule(int clientID, Claim claim, int expenseTypeID)
        {
            int carrierID = 0;
            bool isRuleMet = false;

            // get carrier associated with claim/policy
            using (ClaimManager repository = new ClaimManager()) {
                carrierID = repository.GetCarrier(claim.ClaimID);
            }

            // get business rules for client/rule type id
            using (BusinessRuleManager repository = new BusinessRuleManager()) {
                rules = repository.GetBusinessRules(clientID, Globals.RuleType.SpecificExpenseTypePerCarrier);
            }

            if (carrierID > 0 && expenseTypeID > 0 && rules != null && rules.Count > 0) {
                // build value array
                values = new string[] { carrierID.ToString(), expenseTypeID.ToString() };

                foreach (BusinessRule rule in rules) {
                    XElement ruleXML = XElement.Parse(rule.RuleXML);

                    isRuleMet = base.TestRule(ruleXML, properties, values);

                    if (isRuleMet) {
                        // add exception to queue
                        ruleException = new RuleException();

                        ruleException.BusinessRuleID = rule.BusinessRuleID;

                        ruleException.ClientID = clientID;

                        ruleException.ObjectID = claim.ClaimID;

                        ruleException.ObjectTypeID = (int)Globals.ObjectType.Claim;

                        break;
                    }
                }
            }

            return ruleException;
        }
Ejemplo n.º 5
0
        public List<string> getEmailData(int claimId, int BusinessRuleID)
        {
            List<string> emailData = new List<string>();
            string adjusterEmail = "";

            int adjusterId = 0;
            int superVisorId = 0;
            string adjusterClaimNumber = "";
            string dateRecieved = "";
            int ruleId = 0;
            string businessDescription = "";
            string redFlagName = "";
            string insuredName = "";
            string adjusterName = "";
            ClaimManager ClaimManagerObj = new ClaimManager();
            Claim claimObj = new Claim();
            claimObj = ClaimManagerObj.Get(claimId);
            if (claimObj != null && claimObj.AdjusterID != null)
            {
                adjusterId = Convert.ToInt32(claimObj.AdjusterID);
            }

            if (claimObj != null && claimObj.InsurerClaimNumber != null)
            {
                adjusterClaimNumber = claimObj.InsurerClaimNumber;

            }

            if (claimObj != null && claimObj.DateOpenedReported != null)
            {
                dateRecieved = Convert.ToString(claimObj.DateOpenedReported);
            }

            AdjusterMaster adjusterMasterObj = new AdjusterMaster();

            if (claimObj != null) { adjusterMasterObj = claimObj.AdjusterMaster; }
            if (adjusterMasterObj != null && adjusterMasterObj.email != null)
            {
                adjusterEmail = Convert.ToString(adjusterMasterObj.email);
            }

            if (adjusterMasterObj != null && adjusterMasterObj.adjusterName != null)
            {
                adjusterName = Convert.ToString(adjusterMasterObj.adjusterName);
            }

            if (adjusterMasterObj != null && adjusterMasterObj.SupervisorID != null)
            {
                superVisorId = Convert.ToInt32(adjusterMasterObj.SupervisorID);
            }

            CRM.Data.Entities.SecUser secUserObj = new CRM.Data.Entities.SecUser();

            secUserObj = getSecUser(superVisorId);
            insuredName = claimObj.LeadPolicy.Leads.insuredName;

            BusinessRuleManager BusinessRuleManagerObj = new BusinessRuleManager();
            BusinessRule BusinessRuleObj = new BusinessRule();
            BusinessRuleObj = BusinessRuleManagerObj.GetBusinessRule(BusinessRuleID);
            if (BusinessRuleObj.RuleID != null)
            {
                ruleId = Convert.ToInt32(BusinessRuleObj.RuleID);
            };
            businessDescription = BusinessRuleObj.Description;

            CRM.Data.Entities.Rule ruleObj = new CRM.Data.Entities.Rule();
            ruleObj = BusinessRuleManagerObj.GetRule(ruleId);
            redFlagName = ruleObj.RuleName;
            string encryptedClaimNumber = Core.SecurityManager.EncryptQueryString(claimId.ToString());

            emailData.Add(adjusterEmail);
            emailData.Add(adjusterName);
            emailData.Add(secUserObj.Email);
            emailData.Add(secUserObj.UserName);
            emailData.Add(adjusterClaimNumber);
            emailData.Add(dateRecieved);
            emailData.Add(businessDescription);
            emailData.Add(redFlagName);
            emailData.Add(insuredName);
            emailData.Add(encryptedClaimNumber);
            return emailData;
        }
Ejemplo n.º 6
0
        public List<BusinessRule> getBusinessRuleId(int clientID, int ruleId)
        {
            List<BusinessRule> businessRuleArr = new List<BusinessRule>();
            BusinessRuleManager businessRuleManager = new BusinessRuleManager();

            businessRuleArr = businessRuleManager.GetBusinessRuleThread(clientID, ruleId);
            for (var i = 0; i < businessRuleArr.Count; i++)
            {
                XElement ruleXML = XElement.Parse(businessRuleArr[i].RuleXML.ToString());
                using (RuleHelper ruleHelper = new RuleHelper())
                {
                    XElement conditionLapseTime = ruleHelper.GetElement(ruleXML, "LapseTime");
                    businessRuleArr[i].Description = conditionLapseTime.Element("value").Value;

                    XElement conditionLapseTimeType = ruleHelper.GetElement(ruleXML, "LapseTimeType");
                    businessRuleArr[i].RuleXML = conditionLapseTimeType.Element("value").Value;
                }

            }

            return businessRuleArr;
        }
Ejemplo n.º 7
0
        public bool checkSupervisorSendMail(int businessRuleId)
        {
            BusinessRuleManager businessRuleManagerObj = new BusinessRuleManager();
            BusinessRule businessRuleObj = new BusinessRule();
            businessRuleObj = businessRuleManagerObj.GetBusinessRule(businessRuleId);
            if (businessRuleObj.EmailSupervisor && businessRuleObj.IsActive == true)
            {

                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 8
0
        public void adjusterSendMail(int BusinessRuleID, int clientId, int userId, int claimId)
        {
            BusinessRuleManager businessRuleManagerObj = new BusinessRuleManager();
            BusinessRule businessRuleObj = new BusinessRule();
            businessRuleObj = businessRuleManagerObj.GetBusinessRule(BusinessRuleID);

            List<string> emailData = new List<string>();
            emailData = getEmailData(claimId, BusinessRuleID);

            string adjusterEmail = emailData[0];
            string adjusterName = emailData[1];
            string superVisorEmail = emailData[2];
            string superVisorName = emailData[3];
            string adjusterClaimNumber = emailData[4];
            string dateRecieved = emailData[5];
            string businessDescription = emailData[6];
            string redFlagName = emailData[7];
            string insuredName = emailData[8];
            string encryptedClaimNumber = emailData[9];
            StringBuilder mailContent = mail_content(adjusterEmail, adjusterName, superVisorEmail, superVisorName, adjusterClaimNumber, dateRecieved, businessDescription, redFlagName, insuredName, encryptedClaimNumber);
            string subjectString = get_mail_content(adjusterEmail, adjusterName, superVisorEmail, superVisorName, adjusterClaimNumber, dateRecieved, businessDescription, redFlagName, insuredName, encryptedClaimNumber);

            if (adjusterEmail != "")
            {
                sendMail(adjusterEmail, adjusterName, mailContent, subjectString);
            }
        }
Ejemplo n.º 9
0
        private void bindData()
        {
            List<Rule> rules = null;

            // load all system rule types
            using (BusinessRuleManager repository = new BusinessRuleManager())
            {
                rules = repository.GetAll();
            }

            Core.CollectionManager.FillCollection(ddlRules, "RuleID", "RuleName", rules);

            ddlRules.SelectedIndex = -1;

            bindBusinessRules();
        }
Ejemplo n.º 10
0
        private void bindBusinessRules()
        {
            int clientID = SessionHelper.getClientId();
            List<BusinessRule> rules = null;

            using (BusinessRuleManager repository = new BusinessRuleManager())
            {
                rules = repository.GetBusinessRules(clientID);
                }

            gvBsuinessRules.DataSource = rules;
            gvBsuinessRules.DataBind();
        }
Ejemplo n.º 11
0
        private void bindBusinessRules(int ruleTypeID)
        {
            List<BusinessRule> rules = null;

            using (BusinessRuleManager repository = new BusinessRuleManager())
            {
                rules = repository.GetBusinessRules(ruleTypeID);
            }

            gvBsuinessRules.DataSource = rules;
            gvBsuinessRules.DataBind();
        }
Ejemplo n.º 12
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BusinessRule rule = null;
            int businessRuleID = 0;

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

            businessRuleID = Convert.ToInt32(ViewState["businessRuleID"]);
            lblMessage.Text = "";
            lblMessage.Visible = false;

            try {
                using (BusinessRuleManager repository = new BusinessRuleManager()) {

                    if (businessRuleID == 0) {
                        rule = new BusinessRule();
                        rule.RuleID = (int)Globals.RuleType.AdjusterClaimReview;
                        rule.ClientID = SessionHelper.getClientId();
                    }
                    else {
                        rule = repository.GetBusinessRule(businessRuleID);
                    }

                    if (rule != null) {
                        rule.UpdateDate = DateTime.Now;

                        rule.IsActive = cbxActive.Checked;
                        rule.EmailAdjuster = cbxEmailAdjuster.Checked;
                        rule.EmailSupervisor = cbxEmailSupervisor.Checked;

                        rule.Description = txtDescription.Text;

                        rule.RuleXML = buildRule().ToString();

                        rule = repository.Save(rule);

                        ViewState["businessRuleID"] = rule.BusinessRuleID.ToString();

                        lblMessage.Text = "Rule saved successfully.";
                        lblMessage.CssClass = "ok";
                        lblMessage.Visible = true;
                    }
                }
            }
            catch (Exception ex) {
                Core.EmailHelper.emailError(ex);
                lblMessage.Text = "Rule not saved.";
                lblMessage.CssClass = "error";
                lblMessage.Visible = true;
            }
        }
Ejemplo n.º 13
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BusinessRule rule = null;
            int businessRuleID = 0;

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

            businessRuleID = Convert.ToInt32(ViewState["businessRuleID"]);
            lblMessage.Text = "";
            lblMessage.Visible = false;

            try
            {
                using (BusinessRuleManager repository = new BusinessRuleManager())
                {

                    if (businessRuleID == 0)
                    {
                        rule = new BusinessRule();
                        BusinessRules businessRulesObj = new BusinessRules();
                        rule.RuleID = Convert.ToInt32(Session["ruleId"]);
                        rule.ClientID = SessionHelper.getClientId();
                        rule.CarrierId = Convert.ToInt32(this.ddlCarrier.SelectedValue);
                    }
                    else
                    {
                        rule = repository.GetBusinessRule(businessRuleID);
                    }

                    if (rule != null)
                    {
                        rule.IsActive = cbxActive.Checked;
                        rule.EmailAdjuster = cbxEmailAdjuster.Checked;
                        rule.EmailSupervisor = cbxEmailSupervisor.Checked;
                        rule.CarrierId = Convert.ToInt32(this.ddlCarrier.SelectedValue);
                        rule.Description = txtDescription.Text;
                        ViewState["businessRuleID"] = rule.BusinessRuleID.ToString();
                        rule.RuleXML = buildRule().ToString();
                        rule = repository.Save(rule);
                        string str_query = @"update BusinessRule set
                                            CarrierId = @CarrierId

                                    where

                                        BusinessRuleID=@BusinessRuleID
                                ";

                        using (SqlConnection conn = new SqlConnection(connectionString))
                        using (SqlCommand cmd = new SqlCommand(str_query, conn))
                        {

                            cmd.Parameters.AddWithValue("@BusinessRuleID ", rule.BusinessRuleID);
                            cmd.Parameters.AddWithValue("@CarrierId", rule.CarrierId);

                            conn.Open();

                            cmd.ExecuteNonQuery();
                            conn.Close();
                            conn.Dispose();

                            conn.Close();
                        }

                        lblMessage.Text = "Rule saved successfully.";
                        // notifyUser(txtDescription.Text, SessionHelper.getClientId());
                        lblMessage.CssClass = "ok";
                        lblMessage.Visible = true;
                    }
                }

                Login login = new Login();
                login.setGlobalSession();
                login.formatException();
                login.setRulexception();
            }
            catch (Exception ex)
            {
                Core.EmailHelper.emailError(ex);
                lblMessage.Text = "Rule not saved.";
                lblMessage.CssClass = "error";
                lblMessage.Visible = true;
            }
        }
Ejemplo n.º 14
0
        static void processClaimAssignmentReview()
        {
            List<Claim> claims = null;
            List<BusinessRule> rules = null;
            RuleException ruleException = null;

            // get business rules for client/rule type id
            using (BusinessRuleManager repository = new BusinessRuleManager()) {
                rules = repository.GetBusinessRules(Globals.RuleType.ClaimAssingmentReview);
            }

            if (rules != null && rules.Count > 0) {
                foreach (BusinessRule rule in rules) {
                    using (ClaimAssignmentReview ruleEngine = new ClaimAssignmentReview()) {
                        claims = ruleEngine.TestRule(rule);

                        if (claims != null && claims.Count > 0) {
                            using (TransactionScope scope = new TransactionScope()) {
                                try {
                                    foreach (Claim claim in claims) {
                                        // check exception already exists for this claim
                                        bool exceptionExists = ruleEngine.ExceptionExists((int)rule.ClientID, rule.BusinessRuleID, claim.ClaimID, (int)Globals.ObjectType.Claim);

                                        if (!exceptionExists) {
                                            // add exception to queue
                                            ruleException = new RuleException();

                                            ruleException.BusinessRuleID = rule.BusinessRuleID;

                                            ruleException.ClientID = rule.ClientID;

                                            ruleException.ObjectID = claim.ClaimID;

                                            ruleException.ObjectTypeID = (int)Globals.ObjectType.Claim;

                                            ruleException.UserID = null;

                                            ruleEngine.AddException(ruleException);
                                            //chetu code

                                            CheckSendMail(ruleException);

                                        }
                                    }

                                    // commit transaction
                                    scope.Complete();
                                }
                                catch (Exception ex) {
                                    Core.EmailHelper.emailError(ex);
                                }
                            }
                        }			// if (claims != null && claims.Count > 0)
                    }				// using (ClaimAssignmentReview ruleEngine = new ClaimAssignmentReview())
                }	// foreach
            } // if
        }