Esempio n. 1
0
        public List <ThresholdResult> LoadDataAndCalculate(List <VariableContainer> variableContainers)
        {
            try
            {
                if (variableContainers != null && variableContainers.Count() > 0)
                {
                    string operationPath = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/OperationList.txt");
                    List <OperationEntity> operationEntities = BusinessAction.ParseOperations(operationPath);

                    string thresholdPath = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/ThresholdList.txt");
                    List <ThresholdEntity> thresholdEntities = BusinessAction.ParseRules(thresholdPath);

                    BusinessAction action = new BusinessAction();
                    Dictionary <string, OperationResult> operationResults = action.ExecuteOperations(variableContainers, operationEntities);
                    thresholdResults = action.ExecuteThresholds(variableContainers, thresholdEntities, operationResults);
                }
                else
                {
                    Log.Warn("Error on conversion of variable lists.");
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Error occured: {0}", ex.Message);
            }
            return(thresholdResults);
        }
Esempio n. 2
0
        public ActionResult Create()
        {
            string textboxValue = Request.Form["Variables"];

            if (!string.IsNullOrEmpty(textboxValue))
            {
                List <VariableContainer> variableContainers = new List <VariableContainer>();
                try
                {
                    variableContainers = JsonConvert.DeserializeObject <List <VariableContainer> >(textboxValue);
                }
                catch (Exception ex)
                {
                    Log.ErrorFormat("Error occured at conversion: {0}", ex.Message);
                    return(View());
                }

                try
                {
                    if (variableContainers != null && variableContainers.Count() > 0)
                    {
                        string operationPath = Server.MapPath("~/App_Data/OperationList.txt");
                        List <OperationEntity> operationEntities = BusinessAction.ParseOperations(operationPath);

                        string thresholdPath = Server.MapPath("~/App_Data/ThresholdList.txt");
                        List <ThresholdEntity> thresholdEntities = BusinessAction.ParseRules(thresholdPath);

                        BusinessAction action = new BusinessAction();
                        Dictionary <string, OperationResult> operationResults = action.ExecuteOperations(variableContainers, operationEntities);
                        thresholdResults = action.ExecuteThresholds(variableContainers, thresholdEntities, operationResults);
                    }

                    return(View("LoadData", thresholdResults));
                }
                catch (Exception exc)
                {
                    Log.ErrorFormat("Error occured during calculation: {0}", exc.Message);
                }
            }
            return(View());
        }