Esempio n. 1
0
        public int checkInsertable(int businessruleId, int clientId, int userId, int claimId)
        {
            RuleExceptionManager RuleExceptionManagerObj = new RuleExceptionManager();
            RuleException        RuleExceptionObj        = new RuleException();
            int insertState = 0;

            RuleExceptionObj = RuleExceptionManagerObj.GetRuleException(businessruleId, clientId, userId, claimId);

            try
            {
                bool active = Convert.ToBoolean(RuleExceptionObj.IsActive);
                if (active == false)
                {
                    insertState = 1;
                }
                else
                {
                    insertState = 2;
                }
            }
            catch (Exception e)
            {
                insertState = 0;
            }



            return(insertState);
        }
        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;
        }
Esempio n. 3
0
 public static void CopyToModelState(this RuleException re,
                                     System.Web.Mvc.ModelStateDictionary modelState, string prefix)
 {
     foreach (string key in re.Errors)
     {
         foreach (string value in re.Errors.GetValues(key))
         {
             modelState.AddModelError(prefix + "." + key, value);
         }
     }
 }
        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);
                        }
                    }
                }
            }
        }
        /// <summary>
        ///     Asserts that the two models are equal
        /// </summary>
        /// <typeparam name="TModel">
        ///     The type of the model.
        /// </typeparam>
        /// <param name="expected">The expected value.</param>
        /// <param name="actual">The actual value.</param>
        /// <param name="format">
        ///     The format for the exception message.
        /// </param>
        /// <param name="args">
        ///     The arguments for the exception message.
        /// </param>
        /// <exception cref="FailedAssertException">When check fails</exception>
        public static void AreEqual <TModel>(TModel expected, TModel actual, string format, params object[] args)
        {
            ThrowIfNotModel <TModel>();
            var messages = GetEqualityMessages(expected, actual);

            if (!messages.IsSuccess)
            {
                var rules = new RuleException(messages);
                throw new FailedAssertException(string.Format(format, args), rules);
            }
        }
Esempio n. 6
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    ruleException = null;
                }

                disposed = true;
            }
        }
        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);
                        }
                    }
                }
            }
        }
        //public RuleException TestRule(int clientID, Invoice invoice, int expenseTypeID) {
        //	int carrierID = 0;
        //	bool isRuleMet = false;
        //	List<BusinessRule> rules = null;
        //	string[] properties = { "CarrierID", "ExpenseTypeID" };
        //	string[] values = null;
        //	RuleException ruleException = null;

        //	// get carrier associated with claim/policy
        //	using (ClaimManager repository = new ClaimManager()) {
        //		carrierID = repository.GetCarrier(invoice.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 = invoice.InvoiceID;

        //				ruleException.ObjectTypeID = (int)Globals.ObjectType.Invoice;

        //				break;
        //			}
        //		}
        //	}

        //	return ruleException;
        //}

        public RuleException TestRule(int clientID, Invoice invoice)
        {
            int        carrierID = 0;
            bool       isRuleMet = false;
            List <int> expenseTypeIDCollection = null;

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

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

            expenseTypeIDCollection = InvoiceDetailManager.GetInvoiceExpenseTypeIDCollection(invoice.InvoiceID);

            if (carrierID > 0 && rules != null && rules.Count > 0 && expenseTypeIDCollection != null && expenseTypeIDCollection.Count > 0)
            {
                foreach (int expenseTypeID in expenseTypeIDCollection)
                {
                    // 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 = invoice.InvoiceID;

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

                            break;
                        }
                    }
                }
            }

            return(ruleException);
        }
        public RuleException Save(RuleException exception)
        {
            if (exception.RuleExceptionID == 0)
            {
                exception.ExceptionDate = DateTime.Now;
                exception.IsActive      = true;
                claimRulerDBContext.RuleException.Add(exception);
            }

            claimRulerDBContext.SaveChanges();

            return(exception);
        }
        public RuleException GetRuleException(int businessruleId, int clientId, int userId, int claimId)
        {
            RuleException ruleExceptionObj = new  RuleException();

            ruleExceptionObj = (from x in claimRulerDBContext.RuleException
                                where x.ClientID == clientId &&
                                x.BusinessRuleID == businessruleId &&
                                x.UserID == userId &&
                                x.ObjectID == claimId

                                select x).FirstOrDefault <RuleException>();
            return(ruleExceptionObj);
        }
Esempio n. 11
0
        public void insertRuleException(int BusinessRuleId, int clientID, int userID, int claimId)
        {
            RuleExceptionManager RuleExceptionManagerObj = new RuleExceptionManager();
            RuleException        RuleExceptionObj        = new RuleException();

            RuleExceptionObj.BusinessRuleID = BusinessRuleId;
            RuleExceptionObj.ClientID       = clientID;
            RuleExceptionObj.UserID         = userID;
            RuleExceptionObj.ObjectID       = claimId;
            RuleExceptionObj.ObjectTypeID   = 1;

            RuleExceptionManagerObj.Save(RuleExceptionObj);
        }
 public static void CopyToModelState(this RuleException ruleException, ModelStateDictionary modelState, string prefix)
 {
     foreach (string errorKey in ruleException.Errors)
     {
         foreach (string errorValue in ruleException.Errors.GetValues(errorKey))
         {
             var key = errorKey;
             if (!string.IsNullOrEmpty(prefix))
             {
                 key = prefix + "." + key;
             }
             modelState.AddModelError(key, errorValue);
         }
     }
 }
        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;
        }
Esempio n. 14
0
 public static void CopyToModelState(this RuleException ruleException, ModelStateDictionary modelState, string prefix)
 {
     foreach (string key in ruleException.Errors)
     {
         string[] values = ruleException.Errors.GetValues(key);
         for (int i = 0; i < values.Length; i++)
         {
             string value = values[i];
             if (string.IsNullOrEmpty(prefix))
             {
                 modelState.AddModelError(key, value);
             }
             else
             {
                 modelState.AddModelError(prefix + "." + key, value);
             }
         }
     }
 }
Esempio n. 15
0
        public void Execute(Facts facts)
        {
            if (Evaluate(facts))
            {
                ExecuteActionsByPriority();

                var ruleAttribute = (_object.GetType().GetCustomAttribute(typeof(RuleAttribute)) as RuleAttribute);
                if (ruleAttribute.NextRule != null)
                {
                    ExecuteNextRule(facts);
                }
            }
            else
            {
                RuleException ruleException = null;
                foreach (var errorMessage in _errorMessages)
                {
                    ruleException = new RuleException(errorMessage, ruleException);
                }
                throw new RuleException(_object.GetType().FullName, ruleException);
            }
        }
Esempio n. 16
0
        public int checkInsertable(int businessruleId, int clientId, int userId, int claimId)
        {
            RuleExceptionManager RuleExceptionManagerObj = new RuleExceptionManager();
            RuleException RuleExceptionObj = new RuleException();
            int insertState = 0;

            RuleExceptionObj = RuleExceptionManagerObj.GetRuleException(businessruleId, clientId, userId, claimId);

            try
            {
                bool active = Convert.ToBoolean(RuleExceptionObj.IsActive);
                if (active == false) { insertState = 1; } else { insertState = 2; }

            }
            catch (Exception e)
            {

                insertState = 0;
            }

            return insertState;
        }
Esempio n. 17
0
        public async Task OnExceptionAsync(ExceptionContext context)
        {
            object genericException = new
            {
                code    = "500",
                message = "Ocorreu um erro não identificado"
            };

            if (context.Exception is RuleException)
            {
                RuleException ruleException = context.Exception as RuleException;

                genericException = new
                {
                    code    = ruleException.Code,
                    message = ruleException.Message
                };

                context.Result = await Task.FromResult(BadRequest(genericException));

                return;
            }
            context.Result = await Task.FromResult(BadRequest(genericException));
        }
Esempio n. 18
0
        public void insertRuleException(int BusinessRuleId, int clientID, int userID, int claimId)
        {
            RuleExceptionManager RuleExceptionManagerObj = new RuleExceptionManager();
            RuleException RuleExceptionObj = new RuleException();

            RuleExceptionObj.BusinessRuleID = BusinessRuleId;
            RuleExceptionObj.ClientID = clientID;
            RuleExceptionObj.UserID = userID;
            RuleExceptionObj.ObjectID = claimId;
            RuleExceptionObj.ObjectTypeID = 1;

            RuleExceptionManagerObj.Save(RuleExceptionObj);
        }
Esempio n. 19
0
        public void sendEmailThread()
        {
            var adjusterCount = 0;
            var supervisorCount = 0;

            RuleExceptionManager RuleExceptionManagerObj = new RuleExceptionManager();
            RuleException RuleExceptionObj = new RuleException();
            List<RuleException> RuleExceptionArr = new List<RuleException>();
            Globals gvGet = Globals.Instance();
            int clientID = Convert.ToInt32(gvGet.getClientId());
            RuleExceptionArr = RuleExceptionManagerObj.GetAllException(clientID);

            for (var i = 0; i < RuleExceptionArr.Count; i++)
            {
                int businessRuleId = Convert.ToInt32(RuleExceptionArr[i].BusinessRuleID);
                if (checkAdjusterSendMail(businessRuleId))
                {
                    adjusterCount = adjusterCount + 1;
                }
                if (checkSupervisorSendMail(businessRuleId))
                {
                    supervisorCount = supervisorCount + 1;
                }

            }

            int[] exceptionListAdjuster = new int[adjusterCount];
            int[] formerExceptionListAdjuster = gvGet.getExceptionListAdjuster();

            int[] exceptionListSupervisor = new int[supervisorCount];
            int[] formerExceptionSupervisor = gvGet.getExceptionListSupervisor();

            var j = 0; var k = 0;

            for (var i = 0; i < RuleExceptionArr.Count; i++)
            {
                int businessRuleId = Convert.ToInt32(RuleExceptionArr[i].BusinessRuleID);
                int userId = Convert.ToInt32(RuleExceptionArr[i].UserID);
                int claimId = Convert.ToInt32(RuleExceptionArr[i].ObjectID);

                if (checkAdjusterSendMail(businessRuleId))
                {
                    exceptionListAdjuster[j] = RuleExceptionArr[i].RuleExceptionID;
                    bool canAdd = true;

                    for (var q = 0; q < formerExceptionListAdjuster.Length; q++)
                    {
                        if (RuleExceptionArr[i].RuleExceptionID == formerExceptionListAdjuster[q])
                        {
                            canAdd = false;
                        }

                    }
                    if (canAdd)
                    {

                        adjusterSendMail(businessRuleId, clientID, userId, claimId);

                    }
                    j = j + 1;
                }

                if (checkSupervisorSendMail(businessRuleId))
                {
                    exceptionListSupervisor[k] = RuleExceptionArr[i].RuleExceptionID;
                    bool canAdd = true;

                    for (var q = 0; q < formerExceptionSupervisor.Length; q++)
                    {
                        if (RuleExceptionArr[i].RuleExceptionID == formerExceptionSupervisor[q])
                        {
                            canAdd = false;
                        }

                    }
                    if (canAdd)
                    {

                        supervisorSendMail(businessRuleId, clientID, userId, claimId);

                    }

                    k = k + 1;
                }

            }

            gvGet.setExceptionListAdjuster(exceptionListAdjuster);
            gvGet.setExceptionListSupervisor(exceptionListSupervisor);
        }
Esempio n. 20
0
        public ActionResult Create(AspnetUsers user, string[] selectedObjects, bool isAdministrator)
        {
            // Note checkboxes require special handling in mvc
            // Posts Render an additional <input type="hidden".../> for checkboxes if checked which provides a true and false value.
            // This addresses scenarios where unchecked checkboxes are not sent in the request. 
            // Sending a hidden input makes it possible to know that the checkbox 
            // was present on the page when the request was submitted.
            // as a result of this querying formas parameters produces unexpected results. The workaround institued for
            // this problem takes account that only checkboxes which are selected/changed in selected Objects as passed.
            // Inspect the key value to work out what has changed.       
            try
            {
                IUnitOfWorkFactory factory = new WebSiteUnitOfWorkFactory();
                IAspNetUnitOfWork unitOfWork = factory.GetAspNetUnitOfWork();

                List<CheckBoxListInfo> checkBoxListItems = GetCheckedBoxes(selectedObjects);
                ViewData["listItems"] = checkBoxListItems;
                           
                user = unitOfWork.Save(user, isAdministrator, selectedObjects);

                return RedirectToAction("Index");
            }
            catch (RuleException ex)
            {
                ex.CopyToModelState(ModelState);
                return View();
            }
            catch (Exception ex)
            {
                RuleException rex = new RuleException("error", ex.Message);
                rex.CopyToModelState(ModelState);
                return View();
            }
        }
Esempio n. 21
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);
        }
Esempio n. 22
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
        }
Esempio n. 23
0
        public ActionResult Edit(
            string userId,           
            string submitButton, 
            AspnetUsers user,
            bool isAdministrator, 
            string[] selectedObjects, 
            FormCollection collection)            
        {
            try
            {
                // Note checkboxes require special handling in mvc
                // Posts Render an additional <input type="hidden".../> for checkboxes if checked which provides a true and false value.
                // This addresses scenarios where unchecked checkboxes are not sent in the request. 
                // Sending a hidden input makes it possible to know that the checkbox 
                // was present on the page when the request was submitted.
                // as a result of this querying formas parameters produces unexpected results. The workaround institued for
                // this problem takes account that only checkboxes which are selected/changed in selected Objects as passed.
                // Inspect the key value to work out what has changed.       
                IUnitOfWorkFactory factory = new WebSiteUnitOfWorkFactory();
                IAspNetUnitOfWork unitOfWork = factory.GetAspNetUnitOfWork();

                switch (submitButton)
                {
                    case "Save":
                        ViewData["userWebSites"] = GetUserWebSitesWithDefaultDetails();                      
                        user = unitOfWork.Save(user, isAdministrator, selectedObjects);
                        return RedirectToAction("Index");
                    case "Delete":                      
                        unitOfWork.Delete(user);
                        return RedirectToAction("Index");
                    default:
                        // If they've submitted the form without a submitButton,  
                        // just return the view again. 
                        return RedirectToAction("View");
                }
            }
            catch (Exception ex)
            {
                RuleException rex = new RuleException("error", ex.Message);
                rex.CopyToModelState(ModelState);
                return View();
            }
        }
Esempio n. 24
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
        }
Esempio n. 25
0
 public RuleExceptionEventArgs(RuleException e)
     : base()
 {
     mException = e;
 }
Esempio n. 26
0
 public static void CopyToModelState(this RuleException ruleException, ModelStateDictionary modelState)
 {
     ruleException.CopyToModelState(modelState, "");
 }
Esempio n. 27
0
        protected void btnSaveExpense_Click(object sender, EventArgs e)
        {
            Claim                 claim          = null;
            Claim                 myClaim        = null;
            ClaimExpense          claimExpense   = null;
            AdjusterMaster        adjuster       = null;
            CarrierInvoiceProfile CarrierInvoice = null;

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


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

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

            ClaimManager cm = new ClaimManager();

            myClaim = cm.Get(claimID);

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

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

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

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

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

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

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

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

                    // complete transaction
                    scope.Complete();
                }

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

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

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

                lblMessage.Text     = "Unable to save claim expense.";
                lblMessage.CssClass = "error";
            }
        }
Esempio n. 28
0
        private void saveInvoice()
        {
            int           clientID          = 0;
            int           invoiceID         = 0;
            int           InvoiceLineID     = 0;
            Invoice       invoice           = null;
            InvoiceDetail invoiceDetailLine = null;
            InvoiceDetail invoiceDetail     = null;


            int     nextInvoiceNumber = 0;
            decimal taxAmount         = 0;


            clientID = Core.SessionHelper.getClientId();

            invoiceID = ViewState["InvoiceID"] == null ? 0 : Convert.ToInt32(ViewState["InvoiceID"].ToString());


            if (invoiceID == 0)
            {
                invoice = new Invoice();

                // get id for current lead
                invoice.ClaimID = Core.SessionHelper.getClaimID();

                invoice.IsVoid = false;
            }
            else
            {
                invoice = InvoiceManager.Get(invoiceID);
            }


            //invoice.PolicyID = policy.PolicyType;

            invoice.InvoiceDate    = Convert.ToDateTime(txtInvoiceDate.Text);
            invoice.DueDate        = Convert.ToDateTime(txtDueDate.Text);
            invoice.BillToName     = txtBillTo.Text.Trim();
            invoice.BillToAddress1 = txtBillToAddress1.Text.Trim();
            invoice.BillToAddress2 = txtBillToAddress2.Text.Trim();
            invoice.BillToAddress3 = txtBillToAddress3.Text.Trim();


            try {
                using (TransactionScope scope = new TransactionScope()) {
                    if (invoiceID == 0)
                    {
                        // assign next invoice number to new invoice
                        nextInvoiceNumber = InvoiceManager.GetNextInvoiceNumber(clientID);

                        invoice.InvoiceNumber = nextInvoiceNumber;
                    }

                    invoiceID = InvoiceManager.Save(invoice);

                    // save newly generated invoice id
                    ViewState["InvoiceID"] = invoiceID.ToString();

                    #region get detail line from gridview
                    foreach (GridViewRow row in gvTimeExpense.Rows)
                    {
                        // get detail line from grid
                        invoiceDetailLine = getInvoiceDetailLine(row);

                        if (invoiceDetailLine != null)
                        {
                            if (invoiceDetailLine.InvoiceLineID > 0)
                            {
                                invoiceDetail = InvoiceDetailManager.Get(InvoiceLineID);
                            }
                            else
                            {
                                invoiceDetail = new InvoiceDetail();
                            }

                            // update fields
                            invoiceDetail.InvoiceID       = invoiceID;
                            invoiceDetail.ServiceTypeID   = invoiceDetailLine.ServiceTypeID;
                            invoiceDetail.ExpenseTypeID   = invoiceDetailLine.ExpenseTypeID;
                            invoiceDetail.Comments        = invoiceDetailLine.Comments;
                            invoiceDetail.isBillable      = invoiceDetailLine.isBillable;
                            invoiceDetail.LineAmount      = invoiceDetailLine.LineAmount;
                            invoiceDetail.LineDate        = invoiceDetailLine.LineDate;
                            invoiceDetail.LineDescription = invoiceDetailLine.LineDescription;
                            invoiceDetail.Qty             = invoiceDetailLine.Qty;
                            invoiceDetail.Rate            = invoiceDetailLine.Rate;
                            invoiceDetail.UnitDescription = invoiceDetailLine.UnitDescription;
                            invoiceDetail.Total           = invoiceDetailLine.Total;

                            // save invoice detail
                            InvoiceDetailManager.Save(invoiceDetail);
                        }
                    }                     // foreach
                    #endregion

                    // update invoice total after adding
                    invoice = InvoiceManager.Get(invoiceID);

                    invoice.TotalAmount = invoice.InvoiceDetail.Where(x => x.isBillable == true).Sum(x => x.LineAmount);

                    taxAmount = (invoice.TotalAmount ?? 0) * (invoice.TaxRate / 100);

                    InvoiceManager.Save(invoice);

                    // add invoice to claim diary comment
                    addInvoiceToClaimDiary(invoice, invoiceDetail);

                    // 2014-05-02 apply rule
                    using (SpecificExpenseTypePerCarrier ruleEngine = new SpecificExpenseTypePerCarrier()) {
                        RuleException ruleException = ruleEngine.TestRule(clientID, invoice);

                        if (ruleException != null)
                        {
                            ruleException.UserID = Core.SessionHelper.getUserId();
                            ruleEngine.AddException(ruleException);
                            CheckSendMail(ruleException);
                        }
                    }


                    // complete transaction
                    scope.Complete();
                }                 // using


                // refresh invoice number on UI
                txtInvoiceNumber.Text = (invoice.InvoiceNumber ?? 0).ToString();


                showToolbarButtons();

                lblMessage.Text     = "Invoice was generated successfully.";
                lblMessage.CssClass = "ok";
            }
            catch (Exception ex) {
                lblMessage.Text     = "Error while saving invoice.";
                lblMessage.CssClass = "error";
                Core.EmailHelper.emailError(ex);
            }
        }
Esempio n. 29
0
        public ActionResult Index(long? Id, string submitButton, Schedule schedule, FormCollection collection)
        {
            try
            {
                SelectList hoursList = this.CopyToSelectList("/App_Data/Hours.xml",0);
                SelectList minutesList = this.CopyToSelectList("/App_Data/Minutes.xml",0);
                 ViewData["hoursList"] = hoursList;
                 ViewData["minutesList"] = minutesList;

                switch (submitButton)
                {
                    case "Save":
                        // delegate sending to another controller action 
                        schedule.DaysOfWeekToRun = collection["DaysOfWeekToRun"];
                        schedule.Enabled = true;
                        schedule.CreatedBy = User.Identity.Name;
                        IUnitOfWorkFactory factory = new ScheduMail.UnitsOfWork.WebSiteUnitOfWorkFactory();
                        IScheduleUnitOfWork scheduleUnitOfWork = factory.GetScheduleUnitOfWork();
                        if (schedule.StartDateTime != null)
                            schedule.StartDateTime = new DateTime(schedule.StartDateTime.Value.Year, schedule.StartDateTime.Value.Month, schedule.StartDateTime.Value.Day, Convert.ToInt32(collection["hoursList"]), Convert.ToInt32(collection["minutesList"]), 0);
                        if (schedule.EndDateTime != null)
                            schedule.EndDateTime = new DateTime(schedule.EndDateTime.Value.Year, schedule.EndDateTime.Value.Month, schedule.EndDateTime.Value.Day, Convert.ToInt32(collection["hoursList"]), Convert.ToInt32(collection["minutesList"]), 0);
                        
                        if (Id.HasValue)
                        {
                            schedule.MailId = (long)Id;
                            schedule.Id = scheduleUnitOfWork.GetByMailId(schedule.MailId).Id;
                        }
                        scheduleUnitOfWork.Save(schedule);

                        return RedirectToAction("Index", "WebSiteEMails");
                }
                return View("Index", schedule);

            }

            catch (RuleException ex)
            {

                ex.CopyToModelState(ModelState);
                return View();
            }
            catch (Exception ex)
            {
                RuleException rex = new RuleException("error", ex.Message);
                rex.CopyToModelState(ModelState);
                return View();
            }
        }
Esempio n. 30
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed) {
                if (disposing) {
                    ruleException = null;
                }

                disposed = true;
            }
        }
        public RuleException GetRuleException(int businessruleId, int clientId, int userId, int claimId)
        {
            RuleException ruleExceptionObj = new  RuleException();
            ruleExceptionObj = (from x in claimRulerDBContext.RuleException
                               where x.ClientID == clientId &&
                               x.BusinessRuleID == businessruleId &&
                               x.UserID == userId &&
                               x.ObjectID == claimId

                                select x).FirstOrDefault<RuleException>();
            return ruleExceptionObj;
        }
Esempio n. 32
0
        private void saveInvoice()
        {
            int           clientID          = 0;
            int           invoiceID         = 0;
            int           InvoiceLineID     = 0;
            Invoice       invoice           = null;
            InvoiceDetail invoiceDetailLine = null;
            InvoiceDetail invoiceDetail     = null;

            int     nextInvoiceNumber = 0;
            int     policyID          = 0;
            decimal taxAmount         = 0;


            // get invoice id
            invoiceID = Convert.ToInt32(ViewState["InvoiceID"].ToString());

            clientID = Core.SessionHelper.getClientId();

            // current policy being edited
            policyID = Session["policyID"] == null ? 0 : Convert.ToInt32(Session["policyID"]);
            //policy = LeadPolicyManager.GetByID(policyID);

            if (invoiceID == 0)
            {
                invoice = new Invoice();

                // get id for current lead
                invoice.ClaimID = Core.SessionHelper.getClaimID();

                invoice.IsVoid = false;

                // assign client
                //invoice.ClientID = clientID;

                // hide print button
                //btnPrint.Visible = false;
            }
            else
            {
                invoice = InvoiceManager.Get(invoiceID);

                // show print button
                //btnPrint.Visible = true;
            }


            //invoice.PolicyID = policy.PolicyType;

            invoice.InvoiceDate    = Convert.ToDateTime(txtInvoiceDate.Text);
            invoice.DueDate        = Convert.ToDateTime(txtDueDate.Text);
            invoice.BillToName     = txtBillTo.Text.Trim();
            invoice.BillToAddress1 = txtBillToAddress1.Text.Trim();
            invoice.BillToAddress2 = txtBillToAddress2.Text.Trim();
            invoice.BillToAddress3 = txtBillToAddress3.Text.Trim();

            //invoice.AdjusterID = policy.AdjusterID;

            //invoice.AdjusterInvoiceNumber = txtReferenceNumber.Text.Trim();

            try {
                using (TransactionScope scope = new TransactionScope()) {
                    if (invoiceID == 0)
                    {
                        // assign next invoice number to new invoice
                        nextInvoiceNumber = InvoiceManager.GetNextInvoiceNumber(clientID);

                        invoice.InvoiceNumber = nextInvoiceNumber;
                    }

                    invoiceID = InvoiceManager.Save(invoice);

                    // save newly generated invoice id
                    ViewState["InvoiceID"] = invoiceID.ToString();

                    // check for add/edit invoice detail line
                    InvoiceLineID = ViewState["InvoiceLineID"] == null ? 0 : Convert.ToInt32(ViewState["InvoiceLineID"]);

                    if (InvoiceLineID > 0)
                    {
                        invoiceDetail = InvoiceDetailManager.Get(InvoiceLineID);
                    }
                    else
                    {
                        invoiceDetail = new InvoiceDetail();
                    }


                    // get detail line from gridview footer
                    if (invoiceDetail != null)
                    {
                        invoiceDetailLine = getInvoiceDetailLine();

                        if (invoiceDetailLine.LineDate != null && !string.IsNullOrEmpty(invoiceDetailLine.LineDescription) && invoiceDetailLine.Qty > 0 &&
                            invoiceDetailLine.Rate > 0)
                        {
                            // update fields
                            invoiceDetail.InvoiceID       = invoiceID;
                            invoiceDetail.InvoiceLineID   = InvoiceLineID;
                            invoiceDetail.ServiceTypeID   = invoiceDetailLine.ServiceTypeID;
                            invoiceDetail.Comments        = invoiceDetailLine.Comments;
                            invoiceDetail.isBillable      = invoiceDetailLine.isBillable;
                            invoiceDetail.LineAmount      = invoiceDetailLine.LineAmount;
                            invoiceDetail.LineDate        = invoiceDetailLine.LineDate;
                            invoiceDetail.LineDescription = invoiceDetailLine.LineDescription;
                            invoiceDetail.Qty             = invoiceDetailLine.Qty;
                            invoiceDetail.Rate            = invoiceDetailLine.Rate;
                            invoiceDetail.UnitDescription = invoiceDetailLine.UnitDescription;
                            invoiceDetail.Total           = invoiceDetailLine.Total;

                            // save invoice detail
                            InvoiceDetailManager.Save(invoiceDetail);

                            // clear
                            ViewState["InvoiceLineID"] = "0";

                            // update invoice total after adding
                            invoice = InvoiceManager.Get(invoiceID);

                            invoice.TotalAmount = invoice.InvoiceDetail.Where(x => x.isBillable == true).Sum(x => x.LineAmount);

                            taxAmount = (invoice.TotalAmount ?? 0) * (invoice.TaxRate / 100);

                            //invoice.TotalAmount = invoice.TotalAmount + taxAmount;

                            InvoiceManager.Save(invoice);

                            // update comment
                            updateInvoiceComment(invoice, invoiceDetail);
                        }
                    }

                    // 2014-05-02 apply rule
                    using (SpecificExpenseTypePerCarrier ruleEngine = new SpecificExpenseTypePerCarrier()) {
                        RuleException ruleException = ruleEngine.TestRule(clientID, invoice);

                        if (ruleException != null)
                        {
                            ruleException.UserID = Core.SessionHelper.getUserId();
                            ruleEngine.AddException(ruleException);
                            CheckSendMail(ruleException);
                        }
                    }

                    // complete transaction
                    scope.Complete();
                }

                // refresh invoice detail lines
                bindInvoiceDetails(invoiceID);

                // refresh invoice number on UI
                txtInvoiceNumber.Text = (invoice.InvoiceNumber ?? 0).ToString();

                clearFields();

                showToolbarButtons();
                lblMessage.Text     = "Invoice save successfully.";
                lblMessage.CssClass = "ok";
            }
            catch (Exception ex) {
                lblMessage.Text     = "Error while saving invoice.";
                lblMessage.CssClass = "error";
                Core.EmailHelper.emailError(ex);
            }
        }
        public RuleException Save(RuleException exception)
        {
            if (exception.RuleExceptionID == 0)
            {
                exception.ExceptionDate = DateTime.Now;
                exception.IsActive = true;
                claimRulerDBContext.RuleException.Add(exception);
            }

            claimRulerDBContext.SaveChanges();

            return exception;
        }
Esempio n. 34
0
 public void AddException(RuleException ruleException)
 {
     using (RuleExceptionManager repository = new RuleExceptionManager()) {
         repository.Save(ruleException);
     }
 }
Esempio n. 35
0
 public void AddException(RuleException ruleException)
 {
     using (RuleExceptionManager repository = new RuleExceptionManager()) {
         repository.Save(ruleException);
     }
 }
Esempio n. 36
0
        public void setAdjusterSupervisorList()
        {
            var adjusterCount   = 0;
            var supervisorCount = 0;

            RuleExceptionManager RuleExceptionManagerObj = new RuleExceptionManager();
            RuleException        RuleExceptionObj        = new RuleException();
            List <RuleException> RuleExceptionArr        = new List <RuleException>();
            Globals gvGet    = Globals.Instance();
            int     clientID = Convert.ToInt32(gvGet.getClientId());

            RuleExceptionArr = RuleExceptionManagerObj.GetAllException(clientID);



            for (var i = 0; i < RuleExceptionArr.Count; i++)
            {
                int businessRuleId = Convert.ToInt32(RuleExceptionArr[i].BusinessRuleID);
                if (checkAdjusterSendMail(businessRuleId))
                {
                    adjusterCount = adjusterCount + 1;
                }
                if (checkSupervisorSendMail(businessRuleId))
                {
                    supervisorCount = supervisorCount + 1;
                }
            }

            int[] exceptionListAdjuster       = new int[adjusterCount];
            int[] formerExceptionListAdjuster = gvGet.getExceptionListAdjuster();

            int[] exceptionListSupervisor   = new int[supervisorCount];
            int[] formerExceptionSupervisor = gvGet.getExceptionListSupervisor();

            var j = 0; var k = 0;

            for (var i = 0; i < RuleExceptionArr.Count; i++)
            {
                int businessRuleId = Convert.ToInt32(RuleExceptionArr[i].BusinessRuleID);
                int userId         = Convert.ToInt32(RuleExceptionArr[i].UserID);
                int claimId        = Convert.ToInt32(RuleExceptionArr[i].ObjectID);

                if (checkAdjusterSendMail(businessRuleId))
                {
                    bool canAdd = true;

                    for (var q = 0; q < formerExceptionListAdjuster.Length; q++)
                    {
                        if (RuleExceptionArr[i].RuleExceptionID == formerExceptionListAdjuster[q])
                        {
                            canAdd = false;
                        }
                    }
                    if (canAdd == true)
                    {
                        exceptionListAdjuster[j] = RuleExceptionArr[i].RuleExceptionID;
                    }

                    j = j + 1;
                }

                if (checkSupervisorSendMail(businessRuleId))
                {
                    bool canAdd = true;

                    for (var q = 0; q < formerExceptionSupervisor.Length; q++)
                    {
                        if (RuleExceptionArr[i].RuleExceptionID == formerExceptionSupervisor[q])
                        {
                            canAdd = false;
                        }
                    }
                    if (canAdd == true)
                    {
                        exceptionListSupervisor[k] = RuleExceptionArr[i].RuleExceptionID;
                    }
                    k = k + 1;
                }
            }

            gvGet.setExceptionListAdjuster(exceptionListAdjuster);
            gvGet.setExceptionListSupervisor(exceptionListSupervisor);
        }