public ActionResult SelectAFile(int index)
        {
            TaskManager = (TaskManager)Session["TaskManager"];

            //set current stepinfo based on index
            if (TaskManager != null)
                TaskManager.SetCurrent(index);

            //Get Bus infomations
            SelectFileViewModel model = new SelectFileViewModel();
            if (TaskManager.Bus.ContainsKey(TaskManager.FILENAME))
            {
                model.SelectedFileName = TaskManager.Bus[TaskManager.FILENAME].ToString();
            }

            //get datastuctureType
            model.DataStructureType = GetDataStructureType();
            model.SupportedFileExtentions = UploadWizardHelper.GetExtentionList(model.DataStructureType);

            //Get StepInfo
            model.StepInfo = TaskManager.Current();

            model.serverFileList = GetServerFileList();

            return PartialView(model);
        }
        public ActionResult SelectAFile(object[] data)
        {
            SelectFileViewModel model = new SelectFileViewModel();

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

            if (data != null) TaskManager.AddToBus(data);

            model.StepInfo = TaskManager.Current();

            TaskManager.Current().SetValid(false);

            if (TaskManager != null)
            {
                // is path of FileStream exist
                if (TaskManager.Bus.ContainsKey(TaskManager.FILEPATH))
                {
                    if (IsSupportedExtention(TaskManager))
                    {
                        try
                        {
                            if (GetDataStructureType().Equals(DataStructureType.Structured))
                            {
                                #region structured datastructure
                                    //try save FileStream
                                    string filePath = TaskManager.Bus[TaskManager.FILEPATH].ToString();
                                    //if extention like a makro excel FileStream
                                    if (TaskManager.Bus[TaskManager.EXTENTION].ToString().Equals(".xlsm"))
                                    {
                                        // open FileStream
                                        ExcelReader reader = new ExcelReader();
                                        Stream = reader.Open(filePath);
                                        //Session["Stream"] = Stream;

                                        //check is it template

                                        if (reader.IsTemplate(Stream))
                                        {
                                            TaskManager.Current().SetValid(true);
                                            TaskManager.AddToBus(TaskManager.IS_TEMPLATE, "true");
                                        }
                                        else
                                        {
                                            model.ErrorList.Add(new Error(ErrorType.Other, "File is not a Template"));
                                            TaskManager.AddToBus(TaskManager.IS_TEMPLATE, "false");
                                        }

                                        Stream.Close();
                                    }
                                    else
                                    {
                                        TaskManager.AddToBus(TaskManager.IS_TEMPLATE, "false");
                                        // excel FileStream
                                        if (TaskManager.Bus[TaskManager.EXTENTION].ToString().Equals(".xls"))
                                        {

                                            // open FileStream
                                            ExcelReader reader = new ExcelReader();
                                            Stream = reader.Open(filePath);
                                            //Session["Stream"] = Stream;
                                            TaskManager.Current().SetValid(true);

                                            Stream.Close();
                                        }
                                        // text ór csv FileStream
                                        else if (TaskManager.Bus[TaskManager.EXTENTION].ToString().Equals(".csv") || TaskManager.Bus[TaskManager.EXTENTION].ToString().Equals(".txt"))
                                        {
                                            // open FileStream
                                            AsciiReader reader = new AsciiReader();
                                            Stream = reader.Open(filePath);
                                            //Session["Stream"] = Stream;
                                            TaskManager.Current().SetValid(true);

                                            Stream.Close();
                                        }
                                    }
                                #endregion
                            }

                            if (GetDataStructureType().Equals(DataStructureType.Unstructured))
                            {
                                #region unstructured datastructure
                                //try save FileStream
                                string filePath = TaskManager.Bus[TaskManager.FILEPATH].ToString();

                                if(FileHelper.FileExist( filePath ))
                                {
                                    TaskManager.Current().SetValid(true);
                                }

                                #endregion
                            }

                        }
                        catch
                        {
                            model.ErrorList.Add(new Error(ErrorType.Other, "Cannot access FileStream on server."));
                        }
                    }
                    else
                    {
                        model.ErrorList.Add(new Error(ErrorType.Other, "File is not supported."));
                    }

                }
                else
                {
                    model.ErrorList.Add(new Error(ErrorType.Other, "No FileStream selected or submitted."));
                }

                if (TaskManager.Current().IsValid())
                {
                    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() } });
                }
            }

            model.serverFileList = GetServerFileList();
            //get datastuctureType
            model.DataStructureType = GetDataStructureType();
            model.SupportedFileExtentions = UploadWizardHelper.GetExtentionList(model.DataStructureType);

            return PartialView(model);
        }