Ejemplo n.º 1
0
        public ActionResult SaveSuggestionSelection()
        {
            SelectVerificationModel model = new SelectVerificationModel();

            int?   selectFieldId        = null;
            int?   selectedUnitId       = null;
            int?   selectedDatatypeId   = null;
            string selectedVariableName = null;

            //Keys submitted by Javascript in Verification.cshtml
            foreach (string key in Request.Form.AllKeys)
            {
                if ("headerfieldId" == key)
                {
                    selectFieldId = Convert.ToInt32(Request.Form[key]);
                }
                if ("selectedVariableName" == key)
                {
                    selectedVariableName = Convert.ToString(Request.Form[key]);
                }
                if ("selectedUnitId" == key)
                {
                    selectedUnitId = Convert.ToInt32(Request.Form[key]);
                }
                if ("selectedDataTypeId" == key)
                {
                    var test = Request.Form[key];
                    selectedDatatypeId = Convert.ToInt32(Request.Form[key]);
                }
            }

            EasyUploadTaskManager TaskManager = (EasyUploadTaskManager)Session["TaskManager"];

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS))
            {
                model.AssignedHeaderUnits = (List <Tuple <int, string, UnitInfo> >)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS];
            }

            /*
             * Copy the assignedHeaderUnits, change the entry for which the suggestion was selected
             * */
            if (selectFieldId != null)
            {
                //Find the position of the Tuple that is about to be changed
                Tuple <int, string, UnitInfo> exTuple = model.AssignedHeaderUnits.Where(t => t.Item1 == selectFieldId).FirstOrDefault();
                int i = model.AssignedHeaderUnits.FindIndex(t => t.Equals(exTuple));
                //Insert a new Tuple at this position
                model.AssignedHeaderUnits[i] = new Tuple <int, string, UnitInfo>(exTuple.Item1, selectedVariableName, exTuple.Item3);
            }


            //Save unit and datatype
            if (selectFieldId != null && selectedUnitId != null)
            {
                //Get all units
                List <UnitInfo> availableUnits = (List <UnitInfo>)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS];

                //Get the current unit and clone it
                UnitInfo currentUnit = (UnitInfo)availableUnits.Where(u => u.UnitId == selectedUnitId).FirstOrDefault().Clone();
                currentUnit.SelectedDataTypeId = Convert.ToInt32(selectedDatatypeId);

                //Find the index of the suggestion that is about to be changed
                Tuple <int, string, UnitInfo> existingTuple = model.AssignedHeaderUnits.Where(t => t.Item1 == (int)selectFieldId).FirstOrDefault();
                int j = model.AssignedHeaderUnits.FindIndex(t => t.Equals(existingTuple));
                //Save the new unit with the new datatype
                model.AssignedHeaderUnits[j] = new Tuple <int, string, UnitInfo>(existingTuple.Item1, selectedVariableName, currentUnit);
            }

            TaskManager.AddToBus(EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS, model.AssignedHeaderUnits);

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_HEADERFIELDS))
            {
                model.HeaderFields = (string[])TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_HEADERFIELDS];
            }

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS))
            {
                model.AvailableUnits = (List <UnitInfo>)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS];
            }

            model.Suggestions = (Dictionary <int, List <EasyUploadSuggestion> >)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_ATTRIBUTESUGGESTIONS];

            Session["TaskManager"] = TaskManager;

            //create Model
            model.StepInfo = TaskManager.Current();

            //Submit default datatype id
            //Default unit should be "none" if it exists, otherwise just take the first unit
            UnitInfo currentUnitInfo = model.AvailableUnits.FirstOrDefault(u => u.Name.ToLower() == "none");

            if (currentUnitInfo != null)
            {
                currentUnitInfo = (UnitInfo)currentUnitInfo.Clone();
            }
            else
            {
                currentUnitInfo = (UnitInfo)model.AvailableUnits.FirstOrDefault().Clone();
            }

            DataTypeInfo dtinfo = currentUnitInfo.DataTypeInfos.FirstOrDefault();

            currentUnitInfo.SelectedDataTypeId = dtinfo.DataTypeId;
            ViewData["defaultUnitID"]          = currentUnitInfo.UnitId;
            ViewData["defaultDatatypeID"]      = dtinfo.DataTypeId;

            return(PartialView("Verification", model));
        }
Ejemplo n.º 2
0
        public ActionResult SaveDataTypeSelection()
        {
            int?selectFieldId      = null;
            int?selectedDataTypeId = null;

            //Keys submitted by Javascript in Verification.cshtml
            foreach (string key in Request.Form.AllKeys)
            {
                if ("headerfieldId" == key)
                {
                    selectFieldId = Convert.ToInt32(Request.Form[key]);
                }
                if ("selectedDataTypeId" == key)
                {
                    selectedDataTypeId = Convert.ToInt32(Request.Form[key]);
                }
            }

            SelectVerificationModel model = new SelectVerificationModel();

            EasyUploadTaskManager TaskManager = (EasyUploadTaskManager)Session["TaskManager"];

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS))
            {
                model.AssignedHeaderUnits = (List <Tuple <int, string, UnitInfo> >)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS];
            }

            //Reset the name of the variable and save the new Datatype
            string[] headerFields  = (string[])TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_HEADERFIELDS];
            string   currentHeader = headerFields.ElementAt((int)selectFieldId);
            Tuple <int, string, UnitInfo> existingTuple = model.AssignedHeaderUnits.Where(t => t.Item1 == selectFieldId).FirstOrDefault();

            existingTuple = new Tuple <int, string, UnitInfo>(existingTuple.Item1, existingTuple.Item2, (UnitInfo)existingTuple.Item3.Clone());

            int j = model.AssignedHeaderUnits.FindIndex(i => ((i.Item1 == existingTuple.Item1)));

            model.AssignedHeaderUnits[j] = new Tuple <int, string, UnitInfo>(existingTuple.Item1, currentHeader, existingTuple.Item3);
            model.AssignedHeaderUnits[j].Item3.SelectedDataTypeId = Convert.ToInt32(selectedDataTypeId);

            TaskManager.AddToBus(EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS, model.AssignedHeaderUnits);

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_HEADERFIELDS))
            {
                model.HeaderFields = (string[])TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_HEADERFIELDS];
            }

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS))
            {
                model.AvailableUnits = (List <UnitInfo>)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS];
            }

            //Grab the suggestions from the bus and filter them to only show those, that use the selected datatype
            model.Suggestions = (Dictionary <int, List <EasyUploadSuggestion> >)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_ATTRIBUTESUGGESTIONS];
            //Filter the suggestions to only show those, that use the selected unit
            int index = selectFieldId ?? -1;
            List <EasyUploadSuggestion> suggestionList = null;

            if (model.Suggestions.TryGetValue(index, out suggestionList))
            {
                if (suggestionList != null)
                {
                    foreach (EasyUploadSuggestion suggestion in suggestionList)
                    {
                        suggestion.show = (suggestion.dataTypeID == selectedDataTypeId);
                    }
                }
            }

            Session["TaskManager"] = TaskManager;

            model.StepInfo = TaskManager.Current();

            //Default unit should be "none" if it exists, otherwise just take the first unit
            UnitInfo currentUnitInfo = model.AvailableUnits.FirstOrDefault(u => u.Name.ToLower() == "none");

            if (currentUnitInfo != null)
            {
                currentUnitInfo = (UnitInfo)currentUnitInfo.Clone();
            }
            else
            {
                currentUnitInfo = (UnitInfo)model.AvailableUnits.FirstOrDefault().Clone();
            }

            DataTypeInfo dtinfo = currentUnitInfo.DataTypeInfos.FirstOrDefault();

            currentUnitInfo.SelectedDataTypeId = dtinfo.DataTypeId;
            ViewData["defaultUnitID"]          = currentUnitInfo.UnitId;
            ViewData["defaultDatatypeID"]      = dtinfo.DataTypeId;

            return(PartialView("Verification", model));
        }
Ejemplo n.º 3
0
        public ActionResult SaveUnitSelection()
        {
            int?selectFieldId  = null;
            int?selectOptionId = null;

            //Keys submitted by Javascript in Verification.cshtml
            foreach (string key in Request.Form.AllKeys)
            {
                if ("selectFieldId" == key)
                {
                    selectFieldId = Convert.ToInt32(Request.Form[key]);
                }
                if ("selectOptionId" == key)
                {
                    selectOptionId = Convert.ToInt32(Request.Form[key]);
                }
            }

            SelectVerificationModel model = new SelectVerificationModel();

            EasyUploadTaskManager TaskManager = (EasyUploadTaskManager)Session["TaskManager"];

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS))
            {
                model.AssignedHeaderUnits = (List <Tuple <int, string, UnitInfo> >)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS];
            }

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_ATTRIBUTESUGGESTIONS))
            {
                model.Suggestions = (Dictionary <int, List <EasyUploadSuggestion> >)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_ATTRIBUTESUGGESTIONS];
            }

            /*
             * Find the selected unit and adjust the AssignedHeaderUnits
             * Also resets the Variable name
             * */
            if (selectFieldId != null && selectOptionId != null)
            {
                List <UnitInfo> availableUnits = (List <UnitInfo>)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS];
                string[]        headerFields   = (string[])TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_HEADERFIELDS];

                string   currentHeader = headerFields.ElementAt((int)selectFieldId);
                UnitInfo currentUnit   = availableUnits.Where(u => u.UnitId == selectOptionId).FirstOrDefault();

                Tuple <int, string, UnitInfo> existingTuple = model.AssignedHeaderUnits.Where(t => t.Item1 == (int)selectFieldId).FirstOrDefault();
                if (existingTuple != null)
                {
                    model.AssignedHeaderUnits.Remove(existingTuple);
                }
                model.AssignedHeaderUnits.Add(new Tuple <int, string, UnitInfo>((int)selectFieldId, currentHeader, currentUnit));

                //Set the Datatype to the first one suitable for the selected unit
                if (currentUnit.SelectedDataTypeId < 0)
                {
                    currentUnit.SelectedDataTypeId = currentUnit.DataTypeInfos.FirstOrDefault().DataTypeId;
                }

                //Filter the suggestions to only show those, that use the selected unit
                int index = selectFieldId ?? -1;
                List <EasyUploadSuggestion> suggestionList = null;
                if (model.Suggestions.TryGetValue(index, out suggestionList))
                {
                    if (suggestionList != null)
                    {
                        foreach (EasyUploadSuggestion suggestion in suggestionList)
                        {
                            suggestion.show = (suggestion.unitID == selectOptionId);
                        }
                    }
                }
            }

            TaskManager.AddToBus(EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS, model.AssignedHeaderUnits);

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_HEADERFIELDS))
            {
                model.HeaderFields = (string[])TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_HEADERFIELDS];
            }

            if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS))
            {
                model.AvailableUnits = (List <UnitInfo>)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS];
            }


            Session["TaskManager"] = TaskManager;


            //create Model
            model.StepInfo = TaskManager.Current();

            //Submit default datatype id
            //Default unit should be "none" if it exists, otherwise just take the first unit
            UnitInfo currentUnitInfo = model.AvailableUnits.FirstOrDefault(u => u.Name.ToLower() == "none");

            if (currentUnitInfo != null)
            {
                currentUnitInfo = (UnitInfo)currentUnitInfo.Clone();
            }
            else
            {
                currentUnitInfo = (UnitInfo)model.AvailableUnits.FirstOrDefault().Clone();
            }

            DataTypeInfo dtinfo = currentUnitInfo.DataTypeInfos.FirstOrDefault();

            currentUnitInfo.SelectedDataTypeId = dtinfo.DataTypeId;
            ViewData["defaultUnitID"]          = currentUnitInfo.UnitId;
            ViewData["defaultDatatypeID"]      = dtinfo.DataTypeId;

            return(PartialView("Verification", model));
        }
Ejemplo n.º 4
0
        public ActionResult Verification(int index)
        {
            TaskManager = (EasyUploadTaskManager)Session["TaskManager"];

            List <Dlm.Entities.DataStructure.Unit> tempUnitList = new List <Dlm.Entities.DataStructure.Unit>();
            List <DataType>      allDataypes       = new List <DataType>();
            List <DataAttribute> allDataAttributes = new List <DataAttribute>();

            using (IUnitOfWork unitOfWork = this.GetUnitOfWork())
            {
                //set current stepinfo based on index
                if (TaskManager != null)
                {
                    TaskManager.SetCurrent(index);

                    // remove if existing
                    TaskManager.RemoveExecutedStep(TaskManager.Current());
                }

                SelectVerificationModel model = new SelectVerificationModel();

                //Grab all necessary managers and lists
                //UnitManager unitManager = new UnitManager();
                //this.Disposables.Add(unitManager);

                //DataTypeManager dataTypeManager = new DataTypeManager();
                //this.Disposables.Add(dataTypeManager);

                tempUnitList      = unitOfWork.GetReadOnlyRepository <Dlm.Entities.DataStructure.Unit>().Get().ToList();
                allDataypes       = unitOfWork.GetReadOnlyRepository <DataType>().Get().ToList();
                allDataAttributes = unitOfWork.GetReadOnlyRepository <DataAttribute>().Get().ToList();



                //DataStructureManager dsm = new DataStructureManager();
                //this.Disposables.Add(dsm);

                //DataContainerManager dam = new DataContainerManager();
                //this.Disposables.Add(dam);


                //Important for jumping back to this step
                if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS))
                {
                    model.AssignedHeaderUnits = (List <Tuple <int, string, UnitInfo> >)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS];
                }

                // get all DataTypes for each Units
                foreach (Dlm.Entities.DataStructure.Unit unit in tempUnitList)
                {
                    UnitInfo unitInfo = new UnitInfo();

                    unitInfo.UnitId       = unit.Id;
                    unitInfo.Description  = unit.Description;
                    unitInfo.Name         = unit.Name;
                    unitInfo.Abbreviation = unit.Abbreviation;

                    if (unit.Name.ToLower() == "none")
                    {
                        foreach (DataType fullDataType in allDataypes)
                        {
                            DataTypeInfo dataTypeInfo = new DataTypeInfo();
                            dataTypeInfo.DataTypeId  = fullDataType.Id;
                            dataTypeInfo.Description = fullDataType.Description;
                            dataTypeInfo.Name        = fullDataType.Name;

                            unitInfo.DataTypeInfos.Add(dataTypeInfo);
                        }
                        model.AvailableUnits.Add(unitInfo);
                    }
                    else
                    {
                        Boolean hasDatatype = false; //Make sure only units that have at least one datatype are shown

                        foreach (DataType dummyDataType in unit.AssociatedDataTypes)
                        {
                            if (!hasDatatype)
                            {
                                hasDatatype = true;
                            }

                            DataTypeInfo dataTypeInfo = new DataTypeInfo();

                            DataType fullDataType = allDataypes.Where(p => p.Id == dummyDataType.Id).FirstOrDefault();
                            dataTypeInfo.DataTypeId  = fullDataType.Id;
                            dataTypeInfo.Description = fullDataType.Description;
                            dataTypeInfo.Name        = fullDataType.Name;

                            unitInfo.DataTypeInfos.Add(dataTypeInfo);
                        }
                        if (hasDatatype)
                        {
                            model.AvailableUnits.Add(unitInfo);
                        }
                    }
                }

                //Sort the units by name
                model.AvailableUnits.Sort(delegate(UnitInfo u1, UnitInfo u2)
                {
                    return(String.Compare(u1.Name, u2.Name, StringComparison.InvariantCultureIgnoreCase));
                });

                if (!TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS))
                {
                    TaskManager.AddToBus(EasyUploadTaskManager.VERIFICATION_AVAILABLEUNITS, model.AvailableUnits);
                }

                string filePath = TaskManager.Bus[EasyUploadTaskManager.FILEPATH].ToString();
                string selectedHeaderAreaJson = TaskManager.Bus[EasyUploadTaskManager.SHEET_HEADER_AREA].ToString();

                FileStream fis = null;
                fis = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                ExcelPackage ep = new ExcelPackage(fis);
                fis.Close();

                ExcelWorkbook  excelWorkbook  = ep.Workbook;
                ExcelWorksheet firstWorksheet = excelWorkbook.Worksheets[1];

                string sheetFormatString = Convert.ToString(TaskManager.Bus[EasyUploadTaskManager.SHEET_FORMAT]);

                SheetFormat sheetFormat = 0;
                Enum.TryParse <SheetFormat>(sheetFormatString, true, out sheetFormat);

                model.HeaderFields = GetExcelHeaderFields(firstWorksheet, sheetFormat, selectedHeaderAreaJson).ToArray();

                if (!TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_HEADERFIELDS))
                {
                    TaskManager.AddToBus(EasyUploadTaskManager.VERIFICATION_HEADERFIELDS, model.HeaderFields);
                }


                model.Suggestions = new Dictionary <int, List <EasyUploadSuggestion> >();

                for (int i = 0; i < model.HeaderFields.Length; i++)
                {
                    //Default unit should be "none" if it exists, otherwise just take the first unit
                    UnitInfo currentUnitInfo = model.AvailableUnits.FirstOrDefault(u => u.Name.ToLower() == "none");
                    if (currentUnitInfo != null)
                    {
                        currentUnitInfo = (UnitInfo)currentUnitInfo.Clone();
                    }
                    else
                    {
                        currentUnitInfo = (UnitInfo)model.AvailableUnits.FirstOrDefault().Clone();
                    }

                    DataTypeInfo dtinfo = currentUnitInfo.DataTypeInfos.FirstOrDefault();
                    currentUnitInfo.SelectedDataTypeId = dtinfo.DataTypeId;
                    ViewData["defaultUnitID"]          = currentUnitInfo.UnitId;
                    ViewData["defaultDatatypeID"]      = dtinfo.DataTypeId;

                    if (model.AssignedHeaderUnits.Where(t => t.Item1 == i).FirstOrDefault() == null)
                    {
                        model.AssignedHeaderUnits.Add(new Tuple <int, string, UnitInfo>(i, model.HeaderFields[i], currentUnitInfo));
                    }

                    #region suggestions
                    //Add a variable to the suggestions if the names are similar
                    model.Suggestions.Add(i, new List <EasyUploadSuggestion>());

                    //Calculate similarity metric
                    //Accept suggestion if the similarity is greater than some threshold
                    double threshold = 0.5;
                    IEnumerable <DataAttribute> suggestions = allDataAttributes.Where(att => similarity(att.Name, model.HeaderFields[i]) >= threshold);

                    //Order the suggestions according to the similarity
                    List <DataAttribute> ordered = suggestions.ToList <DataAttribute>();
                    ordered.Sort((x, y) => (similarity(y.Name, model.HeaderFields[i])).CompareTo(similarity(x.Name, model.HeaderFields[i])));

                    //Add the ordered suggestions to the model
                    foreach (DataAttribute att in ordered)
                    {
                        model.Suggestions[i].Add(new EasyUploadSuggestion(att.Name, att.Unit.Id, att.DataType.Id, att.Unit.Name, att.DataType.Name, true));
                    }

                    //Use the following to order suggestions alphabetically instead of ordering according to the metric
                    //model.Suggestions[i] = model.Suggestions[i].Distinct().OrderBy(s => s.attributeName).ToList<EasyUploadSuggestion>();

                    //Each Name-Unit-Datatype-Tuple should be unique
                    model.Suggestions[i] = model.Suggestions[i].Distinct().ToList <EasyUploadSuggestion>();
                    #endregion
                }


                TaskManager.AddToBus(EasyUploadTaskManager.VERIFICATION_ATTRIBUTESUGGESTIONS, model.Suggestions);

                TaskManager.AddToBus(EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS, model.AssignedHeaderUnits);

                // when jumping back to this step
                if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.SHEET_JSON_DATA))
                {
                    if (!String.IsNullOrEmpty(Convert.ToString(TaskManager.Bus[EasyUploadTaskManager.SHEET_JSON_DATA])))
                    {
                    }
                }

                model.StepInfo = TaskManager.Current();

                return(PartialView(model));
            }
        }
Ejemplo n.º 5
0
        public ActionResult Verification(object[] data)
        {
            TaskManager = (EasyUploadTaskManager)Session["TaskManager"];
            SelectVerificationModel model = new SelectVerificationModel();

            model.StepInfo = TaskManager.Current();

            if (TaskManager != null)
            {
                TaskManager.Current().SetValid(false);

                if (TaskManager.Bus.ContainsKey(EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS))
                {
                    List <Tuple <int, String, UnitInfo> > mappedHeaderUnits = (List <Tuple <int, String, UnitInfo> >)TaskManager.Bus[EasyUploadTaskManager.VERIFICATION_MAPPEDHEADERUNITS];
                    //Moved handling of this case to SaveUnitSelection, just leaving it here in case of problems:

                    /*foreach (Tuple<int, String, UnitInfo> tuple in mappedHeaderUnits)
                     * {
                     *
                     *  if (tuple.Item3.SelectedDataTypeId < 0)
                     *  {
                     *      tuple.Item3.SelectedDataTypeId = tuple.Item3.DataTypeInfos.FirstOrDefault().DataTypeId;
                     *  }
                     * }*/
                    model.AssignedHeaderUnits = mappedHeaderUnits;

                    TaskManager.Current().SetValid(true);
                }
                else
                {
                    model.ErrorList.Add(new Error(ErrorType.Other, "Some Areas are not selected."));
                }

                if (TaskManager.Current().valid == true)
                {
                    TaskManager.AddExecutedStep(TaskManager.Current());
                    TaskManager.GoToNext();
                    Session["TaskManager"] = TaskManager;
                    ActionInfo actionInfo = TaskManager.Current().GetActionInfo;
                    return(RedirectToAction(actionInfo.ActionName, actionInfo.ControllerName, new RouteValueDictionary {
                        { "area", actionInfo.AreaName }, { "index", TaskManager.GetCurrentStepInfoIndex() }
                    }));
                }
                else
                {
                    TaskManager.Current().SetStatus(StepStatus.error);

                    //reload model
                    model.StepInfo = TaskManager.Current();
                }
            }

            //Default unit should be "none" if it exists, otherwise just take the first unit
            UnitInfo currentUnitInfo = model.AvailableUnits.FirstOrDefault(u => u.Name.ToLower() == "none");

            if (currentUnitInfo != null)
            {
                currentUnitInfo = (UnitInfo)currentUnitInfo.Clone();
            }
            else
            {
                currentUnitInfo = (UnitInfo)model.AvailableUnits.FirstOrDefault().Clone();
            }

            DataTypeInfo dtinfo = currentUnitInfo.DataTypeInfos.FirstOrDefault();

            currentUnitInfo.SelectedDataTypeId = dtinfo.DataTypeId;
            ViewData["defaultUnitID"]          = currentUnitInfo.UnitId;
            ViewData["defaultDatatypeID"]      = dtinfo.DataTypeId;

            return(PartialView(model));
        }